From 12107d7f5b1889a8a36ba4c3dbe66932492a4eea Mon Sep 17 00:00:00 2001 From: Nandor Date: Thu, 12 Oct 2023 13:22:19 +0200 Subject: [PATCH] test(ui-breadcrumb): migrate old Breadcrumb tests Closes: INSTUI-3865 --- package-lock.json | 14 +- packages/ui-breadcrumb/package.json | 8 +- .../BreadcrumbLink/BreadcrumbLinkLocator.ts | 29 ----- .../__new-tests__/BreadcrumbLink.test.tsx | 123 ++++++++++++++++++ .../__tests__/BreadcrumbLink.test.tsx | 91 ------------- .../src/Breadcrumb/BreadcrumbLink/locator.ts | 27 ---- .../src/Breadcrumb/BreadcrumbLocator.ts | 39 ------ .../__new-tests__/Breadcrumb.test.tsx | 109 ++++++++++++++++ .../Breadcrumb/__tests__/Breadcrumb.test.tsx | 62 --------- .../ui-breadcrumb/src/Breadcrumb/locator.ts | 27 ---- packages/ui-breadcrumb/tsconfig.build.json | 6 +- 11 files changed, 249 insertions(+), 286 deletions(-) delete mode 100644 packages/ui-breadcrumb/src/Breadcrumb/BreadcrumbLink/BreadcrumbLinkLocator.ts create mode 100644 packages/ui-breadcrumb/src/Breadcrumb/BreadcrumbLink/__new-tests__/BreadcrumbLink.test.tsx delete mode 100644 packages/ui-breadcrumb/src/Breadcrumb/BreadcrumbLink/__tests__/BreadcrumbLink.test.tsx delete mode 100644 packages/ui-breadcrumb/src/Breadcrumb/BreadcrumbLink/locator.ts delete mode 100644 packages/ui-breadcrumb/src/Breadcrumb/BreadcrumbLocator.ts create mode 100644 packages/ui-breadcrumb/src/Breadcrumb/__new-tests__/Breadcrumb.test.tsx delete mode 100644 packages/ui-breadcrumb/src/Breadcrumb/__tests__/Breadcrumb.test.tsx delete mode 100644 packages/ui-breadcrumb/src/Breadcrumb/locator.ts diff --git a/package-lock.json b/package-lock.json index 1590a41463..f376da29ad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -53861,10 +53861,12 @@ "prop-types": "^15.8.1" }, "devDependencies": { + "@instructure/ui-axe-check": "8.46.1", "@instructure/ui-babel-preset": "8.46.1", - "@instructure/ui-test-locator": "8.46.1", - "@instructure/ui-test-utils": "8.46.1", - "@instructure/ui-themes": "8.46.1" + "@instructure/ui-scripts": "^8.46.1", + "@instructure/ui-themes": "8.46.1", + "@testing-library/jest-dom": "^5.17.0", + "@testing-library/react": "^14.0.0" }, "peerDependencies": { "react": ">=16.8 <=18" @@ -59591,18 +59593,20 @@ "@babel/runtime": "^7.22.15", "@instructure/emotion": "8.46.1", "@instructure/shared-types": "8.46.1", + "@instructure/ui-axe-check": "8.46.1", "@instructure/ui-babel-preset": "8.46.1", "@instructure/ui-icons": "8.46.1", "@instructure/ui-link": "8.46.1", "@instructure/ui-prop-types": "8.46.1", "@instructure/ui-react-utils": "8.46.1", - "@instructure/ui-test-locator": "8.46.1", - "@instructure/ui-test-utils": "8.46.1", + "@instructure/ui-scripts": "^8.46.1", "@instructure/ui-testable": "8.46.1", "@instructure/ui-themes": "8.46.1", "@instructure/ui-truncate-text": "8.46.1", "@instructure/ui-utils": "8.46.1", "@instructure/ui-view": "8.46.1", + "@testing-library/jest-dom": "^5.17.0", + "@testing-library/react": "^14.0.0", "prop-types": "^15.8.1" } }, diff --git a/packages/ui-breadcrumb/package.json b/packages/ui-breadcrumb/package.json index 6ca003b377..4750452e56 100644 --- a/packages/ui-breadcrumb/package.json +++ b/packages/ui-breadcrumb/package.json @@ -24,9 +24,11 @@ "license": "MIT", "devDependencies": { "@instructure/ui-babel-preset": "8.46.1", - "@instructure/ui-test-locator": "8.46.1", - "@instructure/ui-test-utils": "8.46.1", - "@instructure/ui-themes": "8.46.1" + "@instructure/ui-themes": "8.46.1", + "@instructure/ui-axe-check": "8.46.1", + "@instructure/ui-scripts": "^8.46.1", + "@testing-library/jest-dom": "^5.17.0", + "@testing-library/react": "^14.0.0" }, "dependencies": { "@babel/runtime": "^7.22.15", diff --git a/packages/ui-breadcrumb/src/Breadcrumb/BreadcrumbLink/BreadcrumbLinkLocator.ts b/packages/ui-breadcrumb/src/Breadcrumb/BreadcrumbLink/BreadcrumbLinkLocator.ts deleted file mode 100644 index cf798db80e..0000000000 --- a/packages/ui-breadcrumb/src/Breadcrumb/BreadcrumbLink/BreadcrumbLinkLocator.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2015 - present Instructure, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { locator } from '@instructure/ui-test-locator' - -import { BreadcrumbLink } from './index' - -// @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message -export const BreadcrumbLinkLocator = locator(BreadcrumbLink.selector) diff --git a/packages/ui-breadcrumb/src/Breadcrumb/BreadcrumbLink/__new-tests__/BreadcrumbLink.test.tsx b/packages/ui-breadcrumb/src/Breadcrumb/BreadcrumbLink/__new-tests__/BreadcrumbLink.test.tsx new file mode 100644 index 0000000000..71f308a319 --- /dev/null +++ b/packages/ui-breadcrumb/src/Breadcrumb/BreadcrumbLink/__new-tests__/BreadcrumbLink.test.tsx @@ -0,0 +1,123 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015 - present Instructure, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +import React from 'react' +import { fireEvent, render, screen } from '@testing-library/react' +import '@testing-library/jest-dom/extend-expect' + +import { runAxeCheck } from '@instructure/ui-axe-check' +import { BreadcrumbLink } from '../index' + +const TEST_TEXT_01 = 'Account' +const TEST_LINK = 'http://instructure-test.com' +const TEST_TO = '/example' + +const originalResizeObserver = global.ResizeObserver + +describe('', () => { + beforeAll(() => { + // Mock for ResizeObserver browser API + global.ResizeObserver = jest.fn().mockImplementation(() => ({ + observe: jest.fn(), + unobserve: jest.fn(), + disconnect: jest.fn() + })) + }) + + it('should render an anchor tag when given a href prop', () => { + render({TEST_TEXT_01}) + const anchor = screen.getByRole('link') + + expect(anchor).toHaveAttribute('href', TEST_LINK) + }) + + it('should render as a button and respond to onClick event', () => { + const onClick = jest.fn() + + render({TEST_TEXT_01}) + const button = screen.getByRole('button') + + fireEvent.click(button) + + expect(onClick).toHaveBeenCalledTimes(1) + }) + + it('should allow to prop to pass through', () => { + const { container } = render( + {TEST_TEXT_01} + ) + const link = container.querySelector('a') + + expect(link).toBeInTheDocument() + expect(link).toHaveAttribute('to', TEST_TO) + }) + + it('should not render a link when not given an href prop', () => { + const { container } = render( + {TEST_TEXT_01} + ) + const elementWithHref = container.querySelector('[href]') + const anchor = container.querySelector('a') + const span = container.querySelector('span') + + expect(elementWithHref).toBeNull() + expect(anchor).toBeNull() + expect(span).toBeInTheDocument() + expect(span).toHaveTextContent(TEST_TEXT_01) + }) + + it('should not render a button when not given an onClick prop', () => { + const { container } = render( + {TEST_TEXT_01} + ) + const button = container.querySelector('button') + const span = container.querySelector('span') + + expect(button).toBeNull() + expect(span).toBeInTheDocument() + expect(span).toHaveTextContent(TEST_TEXT_01) + }) + + it('should meet a11y standards as a link', async () => { + const { container } = render( + {TEST_TEXT_01} + ) + const axeCheck = await runAxeCheck(container) + + expect(axeCheck).toBe(true) + }) + + it('should meet a11y standards as a span', async () => { + const { container } = render( + {TEST_TEXT_01} + ) + const axeCheck = await runAxeCheck(container) + + expect(axeCheck).toBe(true) + }) + + afterAll(() => { + global.ResizeObserver = originalResizeObserver + }) +}) diff --git a/packages/ui-breadcrumb/src/Breadcrumb/BreadcrumbLink/__tests__/BreadcrumbLink.test.tsx b/packages/ui-breadcrumb/src/Breadcrumb/BreadcrumbLink/__tests__/BreadcrumbLink.test.tsx deleted file mode 100644 index 5d10a6f87b..0000000000 --- a/packages/ui-breadcrumb/src/Breadcrumb/BreadcrumbLink/__tests__/BreadcrumbLink.test.tsx +++ /dev/null @@ -1,91 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2015 - present Instructure, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -import React from 'react' - -import { expect, mount, stub } from '@instructure/ui-test-utils' - -import { BreadcrumbLink } from '../index' -import { BreadcrumbLinkLocator } from '../BreadcrumbLinkLocator' - -describe('', async () => { - it('should render a anchor tag when given an href prop', async () => { - await mount(Test) - const link = await BreadcrumbLinkLocator.find() - const anchor = await link.find('a') - - expect(anchor.getAttribute('href')).to.equal('#') - }) - - it('should render as a button and respond to onClick event', async () => { - const onClick = stub() - await mount(Test) - const link = await BreadcrumbLinkLocator.find() - const button = await link.find('button') - - await button.click() - - expect(onClick).to.have.been.calledOnce() - }) - - it('should allow to prop to pass through', async () => { - await mount(Test) - const link = await BreadcrumbLinkLocator.find() - expect(link.getAttribute('to')).to.equal('/example') - }) - - it('should not render a link when not given an href prop', async () => { - await mount(Test) - const link = await BreadcrumbLinkLocator.find() - const tagName = link.getTagName() - - expect(tagName).to.not.equal('button') - expect(tagName).to.not.equal('a') - expect(tagName).to.equal('span') - }) - - it('should not render a button when not given an onClick prop', async () => { - await mount(Test) - const link = await BreadcrumbLinkLocator.find() - const tagName = link.getTagName() - - expect(tagName).to.not.equal('button') - expect(tagName).to.not.equal('a') - expect(tagName).to.equal('span') - }) - - it('should meet a11y standards as a link', async () => { - await mount(Test) - const link = await BreadcrumbLinkLocator.find() - - expect(await link.accessible()).to.be.true() - }) - - it('should meet a11y standards as a span', async () => { - await mount(Test) - const link = await BreadcrumbLinkLocator.find() - - expect(await link.accessible()).to.be.true() - }) -}) diff --git a/packages/ui-breadcrumb/src/Breadcrumb/BreadcrumbLink/locator.ts b/packages/ui-breadcrumb/src/Breadcrumb/BreadcrumbLink/locator.ts deleted file mode 100644 index 55dc0a5374..0000000000 --- a/packages/ui-breadcrumb/src/Breadcrumb/BreadcrumbLink/locator.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2015 - present Instructure, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { BreadcrumbLinkLocator } from './BreadcrumbLinkLocator' - -export { BreadcrumbLinkLocator } -export default BreadcrumbLinkLocator diff --git a/packages/ui-breadcrumb/src/Breadcrumb/BreadcrumbLocator.ts b/packages/ui-breadcrumb/src/Breadcrumb/BreadcrumbLocator.ts deleted file mode 100644 index 49838c8424..0000000000 --- a/packages/ui-breadcrumb/src/Breadcrumb/BreadcrumbLocator.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2015 - present Instructure, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { locator } from '@instructure/ui-test-locator' - -import { Breadcrumb } from './index' -import { BreadcrumbLinkLocator } from './BreadcrumbLink/BreadcrumbLinkLocator' - -export { BreadcrumbLinkLocator } - -// @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message -export const BreadcrumbLocator = locator(Breadcrumb.selector, { - findAllLinks: (...args: any[]) => { - return BreadcrumbLinkLocator.findAll(...args) - }, - findLink: (...args: any[]) => { - return BreadcrumbLinkLocator.find(...args) - } -}) diff --git a/packages/ui-breadcrumb/src/Breadcrumb/__new-tests__/Breadcrumb.test.tsx b/packages/ui-breadcrumb/src/Breadcrumb/__new-tests__/Breadcrumb.test.tsx new file mode 100644 index 0000000000..6601cf3fe4 --- /dev/null +++ b/packages/ui-breadcrumb/src/Breadcrumb/__new-tests__/Breadcrumb.test.tsx @@ -0,0 +1,109 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015 - present Instructure, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +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' +const TEST_TEXT_02 = 'Settings' +const TEST_LINK = 'http://instructure-test.com' + +const originalResizeObserver = global.ResizeObserver + +describe('', () => { + beforeAll(() => { + // Mock for ResizeObserver browser API + global.ResizeObserver = jest.fn().mockImplementation(() => ({ + observe: jest.fn(), + unobserve: jest.fn(), + disconnect: jest.fn() + })) + }) + + it('should be accessible', async () => { + const { container } = render( + + {TEST_TEXT_01} + {TEST_TEXT_02} + + ) + const axeCheck = await runAxeCheck(container) + + 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( + + {TEST_TEXT_01} + + ) + + const label = screen.getByLabelText(TEST_LABEL) + + expect(label).toBeInTheDocument() + expect(label).toHaveAttribute('aria-label', TEST_LABEL) + }) + + it('should render an icon as a separator', () => { + const { container } = render( + + {TEST_TEXT_01} + {TEST_TEXT_02} + + ) + const icon = container.querySelector('svg') + + expect(icon).toBeInTheDocument() + expect(icon).toHaveAttribute('aria-hidden', 'true') + }) + + afterAll(() => { + global.ResizeObserver = originalResizeObserver + }) +}) diff --git a/packages/ui-breadcrumb/src/Breadcrumb/__tests__/Breadcrumb.test.tsx b/packages/ui-breadcrumb/src/Breadcrumb/__tests__/Breadcrumb.test.tsx deleted file mode 100644 index 418cce0548..0000000000 --- a/packages/ui-breadcrumb/src/Breadcrumb/__tests__/Breadcrumb.test.tsx +++ /dev/null @@ -1,62 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2015 - present Instructure, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -import React from 'react' - -import { expect, mount, generateA11yTests } from '@instructure/ui-test-utils' - -import { Breadcrumb } from '../index' -import { BreadcrumbLocator } from '../BreadcrumbLocator' -import BreadcrumbExamples from '../__examples__/Breadcrumb.examples' - -describe('', async () => { - it('should render the label as an aria-label attribute', async () => { - await mount( - - Account - - ) - const breadcrumb = await BreadcrumbLocator.find() - const label = await breadcrumb.find(':label(Settings)') - - expect(label.getAttribute('aria-label')).to.equal('Settings') - }) - - describe('with generated examples', async () => { - generateA11yTests(Breadcrumb, BreadcrumbExamples) - }) - - it('should render an icon as a separator', async () => { - await mount( - - Account - Settings - - ) - const breadcrumb = await BreadcrumbLocator.find() - const icon = await breadcrumb.find('svg') - - expect(icon.getAttribute('aria-hidden')).to.equal('true') - }) -}) diff --git a/packages/ui-breadcrumb/src/Breadcrumb/locator.ts b/packages/ui-breadcrumb/src/Breadcrumb/locator.ts deleted file mode 100644 index bdde46db87..0000000000 --- a/packages/ui-breadcrumb/src/Breadcrumb/locator.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2015 - present Instructure, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { BreadcrumbLocator } from './BreadcrumbLocator' - -export { BreadcrumbLocator } -export default BreadcrumbLocator diff --git a/packages/ui-breadcrumb/tsconfig.build.json b/packages/ui-breadcrumb/tsconfig.build.json index dee617ff5f..bead86a356 100644 --- a/packages/ui-breadcrumb/tsconfig.build.json +++ b/packages/ui-breadcrumb/tsconfig.build.json @@ -8,8 +8,6 @@ "include": ["src"], "references": [ { "path": "../ui-babel-preset/tsconfig.build.json" }, - { "path": "../ui-test-locator/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" }, @@ -20,6 +18,8 @@ { "path": "../ui-testable/tsconfig.build.json" }, { "path": "../ui-truncate-text/tsconfig.build.json" }, { "path": "../ui-utils/tsconfig.build.json" }, - { "path": "../ui-view/tsconfig.build.json" } + { "path": "../ui-view/tsconfig.build.json" }, + { "path": "../ui-axe-check/tsconfig.build.json" }, + { "path": "../ui-scripts/tsconfig.build.json" } ] }