Skip to content

Commit

Permalink
test(ui-breadcrumb): migrate old Breadcrumb tests
Browse files Browse the repository at this point in the history
Closes: INSTUI-3865
  • Loading branch information
git-nandor committed Oct 12, 2023
1 parent 24be01a commit bd2353f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
6 changes: 2 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions packages/ui-breadcrumb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@
"license": "MIT",
"devDependencies": {
"@instructure/ui-babel-preset": "8.46.0",
"@instructure/ui-test-locator": "8.46.0",
"@instructure/ui-test-utils": "8.46.0",
"@instructure/ui-themes": "8.46.0",
"@instructure/ui-axe-check": "8.46.0",
"@instructure/ui-scripts": "^8.46.0",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^14.0.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ import React from 'react'
import { render, screen } from '@testing-library/react'
import '@testing-library/jest-dom/extend-expect'

// eslint-disable-next-line no-restricted-imports
import { generateA11yTests } from '@instructure/ui-scripts/lib/test/generateA11yTests'
import { runAxeCheck } from '@instructure/ui-axe-check'
import { Breadcrumb } from '../index'
import BreadcrumbExamples from '../__examples__/Breadcrumb.examples'

const TEST_LABEL = 'You are here:'
const TEST_TEXT_01 = 'Account'
Expand Down Expand Up @@ -58,6 +61,22 @@ describe('<Breadcrumb />', () => {
expect(axeCheck).toBe(true)
})

describe('with generated examples', () => {
const generatedComponents = generateA11yTests(
Breadcrumb,
BreadcrumbExamples
)

it.each(generatedComponents)(
'should be accessible with example: $description',
async ({ content }) => {
const { container } = render(content)
const axeCheck = await runAxeCheck(container)
expect(axeCheck).toBe(true)
}
)
})

it('should render the label as an aria-label attribute', () => {
render(
<Breadcrumb label={TEST_LABEL}>
Expand Down
4 changes: 2 additions & 2 deletions packages/ui-breadcrumb/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"include": ["src"],
"references": [
{ "path": "../ui-babel-preset/tsconfig.build.json" },
{ "path": "../ui-test-utils/tsconfig.build.json" },
{ "path": "../ui-themes/tsconfig.build.json" },
{ "path": "../emotion/tsconfig.build.json" },
{ "path": "../shared-types/tsconfig.build.json" },
Expand All @@ -20,6 +19,7 @@
{ "path": "../ui-truncate-text/tsconfig.build.json" },
{ "path": "../ui-utils/tsconfig.build.json" },
{ "path": "../ui-view/tsconfig.build.json" },
{ "path": "../ui-axe-check/tsconfig.build.json" }
{ "path": "../ui-axe-check/tsconfig.build.json" },
{ "path": "../ui-scripts/tsconfig.build.json" }
]
}

0 comments on commit bd2353f

Please sign in to comment.