Skip to content

Commit f9fad21

Browse files
committed
test(react/vanilla-utils/atomWithReducer): replace 'userEvent' with 'fireEvent', 'findByText' with 'getByText'
1 parent 5a0345a commit f9fad21

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

tests/react/vanilla-utils/atomWithReducer.test.tsx

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { StrictMode } from 'react'
2-
import { render, screen } from '@testing-library/react'
3-
import userEvent from '@testing-library/user-event'
2+
import { fireEvent, render, screen } from '@testing-library/react'
43
import { expect, it } from 'vitest'
54
import { useAtom } from 'jotai/react'
65
import { atomWithReducer } from 'jotai/vanilla/utils'
76

8-
it('atomWithReducer with optional action argument', async () => {
7+
it('atomWithReducer with optional action argument', () => {
98
const reducer = (state: number, action?: 'INCREASE' | 'DECREASE') => {
109
switch (action) {
1110
case 'INCREASE':
@@ -36,19 +35,19 @@ it('atomWithReducer with optional action argument', async () => {
3635
</StrictMode>,
3736
)
3837

39-
expect(await screen.findByText('count: 0')).toBeInTheDocument()
38+
expect(screen.getByText('count: 0')).toBeInTheDocument()
4039

41-
await userEvent.click(screen.getByText('dispatch INCREASE'))
42-
expect(await screen.findByText('count: 1')).toBeInTheDocument()
40+
fireEvent.click(screen.getByText('dispatch INCREASE'))
41+
expect(screen.getByText('count: 1')).toBeInTheDocument()
4342

44-
await userEvent.click(screen.getByText('dispatch empty'))
45-
expect(await screen.findByText('count: 1')).toBeInTheDocument()
43+
fireEvent.click(screen.getByText('dispatch empty'))
44+
expect(screen.getByText('count: 1')).toBeInTheDocument()
4645

47-
await userEvent.click(screen.getByText('dispatch DECREASE'))
48-
expect(await screen.findByText('count: 0')).toBeInTheDocument()
46+
fireEvent.click(screen.getByText('dispatch DECREASE'))
47+
expect(screen.getByText('count: 0')).toBeInTheDocument()
4948
})
5049

51-
it('atomWithReducer with non-optional action argument', async () => {
50+
it('atomWithReducer with non-optional action argument', () => {
5251
const reducer = (state: number, action: 'INCREASE' | 'DECREASE') => {
5352
switch (action) {
5453
case 'INCREASE':
@@ -76,11 +75,11 @@ it('atomWithReducer with non-optional action argument', async () => {
7675
</StrictMode>,
7776
)
7877

79-
expect(await screen.findByText('count: 0')).toBeInTheDocument()
78+
expect(screen.getByText('count: 0')).toBeInTheDocument()
8079

81-
await userEvent.click(screen.getByText('dispatch INCREASE'))
82-
expect(await screen.findByText('count: 1')).toBeInTheDocument()
80+
fireEvent.click(screen.getByText('dispatch INCREASE'))
81+
expect(screen.getByText('count: 1')).toBeInTheDocument()
8382

84-
await userEvent.click(screen.getByText('dispatch DECREASE'))
85-
expect(await screen.findByText('count: 0')).toBeInTheDocument()
83+
fireEvent.click(screen.getByText('dispatch DECREASE'))
84+
expect(screen.getByText('count: 0')).toBeInTheDocument()
8685
})

0 commit comments

Comments
 (0)