Skip to content

Commit bbdde99

Browse files
committed
test(ui-flex): migrate old Flex tests
1 parent dd6faf4 commit bbdde99

File tree

5 files changed

+111
-102
lines changed

5 files changed

+111
-102
lines changed

package-lock.json

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/ui-flex/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,13 @@
3232
"prop-types": "^15.8.1"
3333
},
3434
"devDependencies": {
35+
"@instructure/ui-axe-check": "10.12.0",
3536
"@instructure/ui-babel-preset": "10.12.0",
3637
"@instructure/ui-test-utils": "10.12.0",
37-
"@instructure/ui-themes": "10.12.0"
38+
"@instructure/ui-themes": "10.12.0",
39+
"@testing-library/jest-dom": "^6.6.3",
40+
"@testing-library/react": "^16.0.1",
41+
"vitest": "^2.1.8"
3842
},
3943
"peerDependencies": {
4044
"react": ">=16.14 <=18"

packages/ui-flex/src/Flex/Item/__tests__/FlexItem.test.tsx renamed to packages/ui-flex/src/Flex/Item/__new-tests__/FlexItem.test.tsx

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,39 @@
2323
*/
2424

2525
import React from 'react'
26+
import { render, waitFor } from '@testing-library/react'
27+
import { vi } from 'vitest'
2628

27-
import { expect, mount, within, wait, stub } from '@instructure/ui-test-utils'
29+
import '@testing-library/jest-dom'
30+
import { runAxeCheck } from '@instructure/ui-axe-check'
2831
import { Item } from '../index'
2932

30-
describe('<Item />', async () => {
33+
describe('<Item />', () => {
3134
it('should render children', async () => {
32-
const subject = await mount(<Item>Flex item 1</Item>)
33-
const item = within(subject.getDOMNode())
34-
expect(item.find(':contains(Flex item 1)')).to.exist()
35+
const { container } = render(<Item>Flex item 1</Item>)
36+
const item = container.querySelector('[class$="-flexItem"]')
37+
38+
expect(item).toBeInTheDocument()
39+
expect(item).toHaveTextContent('Flex item 1')
3540
})
3641

3742
it('should support an elementRef prop', async () => {
38-
const elementRef = stub()
43+
const elementRef = vi.fn()
3944

40-
const subject = await mount(
45+
const { container } = render(
4146
<Item elementRef={elementRef}>Flex item 2</Item>
4247
)
48+
const item = container.querySelector('[class$="-flexItem"]')
4349

44-
await wait(() => {
45-
expect(elementRef).to.have.been.calledWith(subject.getDOMNode())
50+
await waitFor(() => {
51+
expect(elementRef).toHaveBeenCalledWith(item)
4652
})
4753
})
4854

4955
it('should meet a11y standards', async () => {
50-
const subject = await mount(<Item>Flex item 3</Item>)
51-
52-
const item = within(subject.getDOMNode())
56+
const { container } = render(<Item>Flex item 3</Item>)
57+
const axeCheck = await runAxeCheck(container)
5358

54-
expect(await item.accessible()).to.be.true()
59+
expect(axeCheck).toBe(true)
5560
})
5661
})

0 commit comments

Comments
 (0)