Skip to content

Commit

Permalink
fix(test): resolve act warning
Browse files Browse the repository at this point in the history
  • Loading branch information
irudoy committed Sep 26, 2022
1 parent 161551e commit ffd7e1a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import React, { useState } from 'react'
import PhotoSwipe from 'photoswipe'
import { render, screen, act } from '@testing-library/react'
import { render, screen, act, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { NoRefError } from '../no-ref-error'
import shuffle from '../helpers/shuffle'
Expand Down Expand Up @@ -318,10 +318,16 @@ describe('gallery', () => {

render(<TestGalleryWithStatefulItem />)

await user.click(screen.getByRole('button'))
await user.click(screen.getAllByRole('img')[0])
await waitFor(() => {
user.click(screen.getByRole('button'))
})
await waitFor(() => {
user.click(screen.getAllByRole('img')[0])
})

expect(PhotoSwipeMocked).toHaveBeenCalledWith(...photoswipeArgsMock(0))
await waitFor(() => {
expect(PhotoSwipeMocked).toHaveBeenCalledWith(...photoswipeArgsMock(0))
})
})

test('should throw when there is no ref and more than one item', async () => {
Expand Down

0 comments on commit ffd7e1a

Please sign in to comment.