diff --git a/package-lock.json b/package-lock.json index f09e9f122f..0769d8afdc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -53915,10 +53915,13 @@ "prop-types": "^15.8.1" }, "devDependencies": { + "@instructure/ui-axe-check": "8.44.0", "@instructure/ui-babel-preset": "8.44.0", "@instructure/ui-color-utils": "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" @@ -59478,6 +59481,7 @@ "@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-color-utils": "8.44.0", "@instructure/ui-react-utils": "8.44.0", @@ -59485,6 +59489,8 @@ "@instructure/ui-testable": "8.44.0", "@instructure/ui-themes": "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-byline/src/Byline/__new-tests__/Byline.test.tsx b/packages/ui-byline/src/Byline/__new-tests__/Byline.test.tsx index f2a5e20ef6..e4927f03ee 100644 --- a/packages/ui-byline/src/Byline/__new-tests__/Byline.test.tsx +++ b/packages/ui-byline/src/Byline/__new-tests__/Byline.test.tsx @@ -116,16 +116,6 @@ describe('', () => { expect(figureElement).toBeInTheDocument() }) - it(`should not allow the 'as' prop`, () => { - const spyOnConsole = jest.spyOn(console, 'error').mockImplementation() - renderByline({ as: 'foo' }) - const warningMessage = spyOnConsole.mock.calls[0][0] - - expect(warningMessage).toBe("Warning: [Byline] prop 'as' is not allowed.") - - spyOnConsole.mockRestore() - }) - describe('when passing down props to View', () => { let spyOnConsoleError: jest.SpyInstance const customAllowedProps: { [key: string]: string } = { margin: 'small' } diff --git a/packages/ui-byline/src/Byline/__tests__/Byline.test.tsx b/packages/ui-byline/src/Byline/__tests__/Byline.test.tsx deleted file mode 100644 index 9eaa5f62d3..0000000000 --- a/packages/ui-byline/src/Byline/__tests__/Byline.test.tsx +++ /dev/null @@ -1,126 +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, find, mount, stub, within } from '@instructure/ui-test-utils' -import { Byline } from '../index' -import { View } from '@instructure/ui-view' - -describe('', async () => { - // eslint-disable-next-line max-len - const image = ( - - ) - - it('should render', async () => { - const subject = await mount( - - {image} - - ) - - expect(subject.getDOMNode()).to.exist() - }) - - it('should pass down div and its contents via the description property', async () => { - const description = ( -
-

- Clickable Heading -

-

Something here

-
- ) - - const subject = await mount( - {image} - ) - - const media = within(subject.getDOMNode()) - expect(await media.find(':contains(Clickable Heading)')).to.exist() - }) - - it('should meet a11y standards', async () => { - const subject = await mount( - - {image} - - ) - - const media = within(subject.getDOMNode()) - expect(await media.accessible()).to.be.true() - }) - - it(`should render a figure by default`, async () => { - expect(await mount({image})) - expect(await find('figure')).to.exist() - }) - - it(`should not allow the 'as' prop`, async () => { - const consoleError = stub(console, 'error') - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore intentionally wrong prop - await mount({image}) - expect(consoleError).to.be.calledWith( - "Warning: [Byline] prop 'as' is not allowed." - ) - }) - - describe('when passing down props to View', async () => { - const allowedProps: Record = { - margin: 'small' - } - - const ignoreProps = ['elementRef', 'children'] - - View.allowedProps - .filter((prop) => !ignoreProps.includes(prop)) - .forEach((prop) => { - if (Object.keys(allowedProps).indexOf(prop) < 0) { - it(`should NOT allow the '${prop}' prop`, async () => { - const consoleError = stub(console, 'error') - const warning = `Warning: [Byline] prop '${prop}' is not allowed.` - const props = { - [prop]: 'foo' - } - - await mount({image}) - expect(consoleError).to.be.calledWith(warning) - }) - } else { - it(`should allow the '${prop}' prop`, async () => { - const props = { [prop]: allowedProps[prop] } - const consoleError = stub(console, 'error') - - await mount({image}) - expect(consoleError).to.not.be.called() - }) - } - }) - }) -})