Skip to content

Commit

Permalink
tweak some tests for react 18
Browse files Browse the repository at this point in the history
  • Loading branch information
dai-shi committed Oct 3, 2021
1 parent a4c455f commit f38921b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 23 deletions.
24 changes: 12 additions & 12 deletions tests/async.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ it('does not show async stale result', async () => {
}

const { getByText, findByText } = render(
<StrictMode>
<>
<Provider>
<Suspense fallback="loading">
<Counter />
Expand All @@ -56,7 +56,7 @@ it('does not show async stale result', async () => {
<DelayedCounter />
</Suspense>
</Provider>
</StrictMode>
</>
)

await findByText('loading')
Expand Down Expand Up @@ -329,13 +329,13 @@ it('updates an async atom in child useEffect on remount without setTimeout', asy
}

const { getByText, findByText } = render(
<StrictMode>
<>
<Provider>
<Suspense fallback="loading">
<Parent />
</Suspense>
</Provider>
</StrictMode>
</>
)

await findByText('count: 1')
Expand Down Expand Up @@ -380,13 +380,13 @@ it('updates an async atom in child useEffect on remount', async () => {
}

const { getByText, findByText } = render(
<StrictMode>
<>
<Provider>
<Suspense fallback="loading">
<Parent />
</Suspense>
</Provider>
</StrictMode>
</>
)

await findByText('count: 1')
Expand Down Expand Up @@ -426,13 +426,13 @@ it('async get and useEffect on parent', async () => {
}

const { getByText, findByText } = render(
<StrictMode>
<>
<Provider>
<Suspense fallback="loading">
<Parent />
</Suspense>
</Provider>
</StrictMode>
</>
)

await findByText('loading')
Expand Down Expand Up @@ -471,13 +471,13 @@ it('async get with another dep and useEffect on parent', async () => {
}

const { getByText, findByText } = render(
<StrictMode>
<>
<Provider>
<Suspense fallback="loading">
<Parent />
</Suspense>
</Provider>
</StrictMode>
</>
)

await findByText('loading')
Expand Down Expand Up @@ -638,13 +638,13 @@ it('a derived atom from a newly created async atom (#351)', async () => {
}

const { getByText, findByText } = render(
<StrictMode>
<>
<Provider>
<Suspense fallback="loading">
<Counter />
</Suspense>
</Provider>
</StrictMode>
</>
)

await findByText('loading')
Expand Down
14 changes: 5 additions & 9 deletions tests/basic.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -795,11 +795,7 @@ it('changes atom from parent (#273, #275)', async () => {
const Item = ({ id }: { id: string }) => {
const a = useMemo(() => (id === 'a' ? atomA : atomB), [id])
const [atomValue] = useAtom(a)
return (
<div>
commits: {useCommitCount()}, id: {atomValue.id}
</div>
)
return <div>id: {atomValue.id}</div>
}

const App = () => {
Expand All @@ -819,16 +815,16 @@ it('changes atom from parent (#273, #275)', async () => {
</Provider>
)

await findByText('commits: 1, id: a')
await findByText('id: a')

fireEvent.click(getByText('atom a'))
await findByText('commits: 1, id: a')
await findByText('id: a')

fireEvent.click(getByText('atom b'))
await findByText('commits: 2, id: b')
await findByText('id: b')

fireEvent.click(getByText('atom a'))
await findByText('commits: 3, id: a')
await findByText('id: a')
})

it('should be able to use a double derived atom twice and useEffect (#373)', async () => {
Expand Down
4 changes: 2 additions & 2 deletions tests/utils/useUpdateAtom.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ it('useUpdateAtom does not trigger rerender in component', async () => {
}

const { getByText } = render(
<StrictMode>
<>
<Provider>
<Parent />
</Provider>
</StrictMode>
</>
)

await waitFor(() => {
Expand Down

0 comments on commit f38921b

Please sign in to comment.