From 9675bb03c2325ec1f2b2b8507ecda332a6a09084 Mon Sep 17 00:00:00 2001 From: Nandor Date: Mon, 2 Oct 2023 14:57:37 +0200 Subject: [PATCH] test(ui-breadcrumb): delete old tests --- package-lock.json | 10 +- .../__tests__/BreadcrumbLink.test.tsx | 91 ------------------- .../Breadcrumb/__tests__/Breadcrumb.test.tsx | 62 ------------- 3 files changed, 7 insertions(+), 156 deletions(-) delete mode 100644 packages/ui-breadcrumb/src/Breadcrumb/BreadcrumbLink/__tests__/BreadcrumbLink.test.tsx delete mode 100644 packages/ui-breadcrumb/src/Breadcrumb/__tests__/Breadcrumb.test.tsx diff --git a/package-lock.json b/package-lock.json index f09e9f122f..698d6c2552 100644 --- a/package-lock.json +++ b/package-lock.json @@ -53858,10 +53858,12 @@ "prop-types": "^15.8.1" }, "devDependencies": { + "@instructure/ui-axe-check": "8.44.0", "@instructure/ui-babel-preset": "8.44.0", - "@instructure/ui-test-locator": "8.44.0", "@instructure/ui-test-utils": "8.44.0", - "@instructure/ui-themes": "8.44.0" + "@instructure/ui-themes": "8.44.0", + "@testing-library/jest-dom": "^5.17.0", + "@testing-library/react": "^14.0.0" }, "peerDependencies": { "react": ">=16.8 <=18" @@ -59430,18 +59432,20 @@ "@babel/runtime": "^7.22.15", "@instructure/emotion": "8.44.0", "@instructure/shared-types": "8.44.0", + "@instructure/ui-axe-check": "8.44.0", "@instructure/ui-babel-preset": "8.44.0", "@instructure/ui-icons": "8.44.0", "@instructure/ui-link": "8.44.0", "@instructure/ui-prop-types": "8.44.0", "@instructure/ui-react-utils": "8.44.0", - "@instructure/ui-test-locator": "8.44.0", "@instructure/ui-test-utils": "8.44.0", "@instructure/ui-testable": "8.44.0", "@instructure/ui-themes": "8.44.0", "@instructure/ui-truncate-text": "8.44.0", "@instructure/ui-utils": "8.44.0", "@instructure/ui-view": "8.44.0", + "@testing-library/jest-dom": "^5.17.0", + "@testing-library/react": "^14.0.0", "prop-types": "^15.8.1" } }, 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/__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') - }) -})