Skip to content

Commit

Permalink
test: add option to skip display name check
Browse files Browse the repository at this point in the history
  • Loading branch information
joshblack committed Oct 31, 2024
1 parent 6c5db48 commit faadbfe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
7 changes: 6 additions & 1 deletion packages/react/src/BranchName/__tests__/BranchName.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import axe from 'axe-core'
import {FeatureFlags} from '../../FeatureFlags'

describe('BranchName', () => {
behavesAsComponent({Component: BranchName})
behavesAsComponent({
Component: BranchName,
options: {
skipDisplayName: true,
},
})

checkExports('BranchName', {
default: BranchName,
Expand Down
9 changes: 6 additions & 3 deletions packages/react/src/utils/testing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ export function unloadCSS(path: string) {
interface Options {
skipAs?: boolean
skipSx?: boolean
skipDisplayName?: boolean
}

interface BehavesAsComponent {
Expand Down Expand Up @@ -221,9 +222,11 @@ export function behavesAsComponent({Component, toRender, options}: BehavesAsComp
})
}

it('sets a valid displayName', () => {
expect(Component.displayName).toMatch(COMPONENT_DISPLAY_NAME_REGEX)
})
if (!options.skipDisplayName) {
it('sets a valid displayName', () => {
expect(Component.displayName).toMatch(COMPONENT_DISPLAY_NAME_REGEX)
})
}
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down

0 comments on commit faadbfe

Please sign in to comment.