|
1 | 1 | 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' |
4 | 3 | import { expect, it } from 'vitest'
|
5 | 4 | import { useAtom } from 'jotai/react'
|
6 | 5 | import { atomWithReducer } from 'jotai/vanilla/utils'
|
7 | 6 |
|
8 |
| -it('atomWithReducer with optional action argument', async () => { |
| 7 | +it('atomWithReducer with optional action argument', () => { |
9 | 8 | const reducer = (state: number, action?: 'INCREASE' | 'DECREASE') => {
|
10 | 9 | switch (action) {
|
11 | 10 | case 'INCREASE':
|
@@ -36,19 +35,19 @@ it('atomWithReducer with optional action argument', async () => {
|
36 | 35 | </StrictMode>,
|
37 | 36 | )
|
38 | 37 |
|
39 |
| - expect(await screen.findByText('count: 0')).toBeInTheDocument() |
| 38 | + expect(screen.getByText('count: 0')).toBeInTheDocument() |
40 | 39 |
|
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() |
43 | 42 |
|
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() |
46 | 45 |
|
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() |
49 | 48 | })
|
50 | 49 |
|
51 |
| -it('atomWithReducer with non-optional action argument', async () => { |
| 50 | +it('atomWithReducer with non-optional action argument', () => { |
52 | 51 | const reducer = (state: number, action: 'INCREASE' | 'DECREASE') => {
|
53 | 52 | switch (action) {
|
54 | 53 | case 'INCREASE':
|
@@ -76,11 +75,11 @@ it('atomWithReducer with non-optional action argument', async () => {
|
76 | 75 | </StrictMode>,
|
77 | 76 | )
|
78 | 77 |
|
79 |
| - expect(await screen.findByText('count: 0')).toBeInTheDocument() |
| 78 | + expect(screen.getByText('count: 0')).toBeInTheDocument() |
80 | 79 |
|
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() |
83 | 82 |
|
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() |
86 | 85 | })
|
0 commit comments