Skip to content

Commit

Permalink
deps: update @testing-library/react to v14 (#2578)
Browse files Browse the repository at this point in the history
* deps: update @testing-library/react to v14

* test: remove the wrong assertion
  • Loading branch information
koba04 committed Apr 23, 2023
1 parent c2b2fb7 commit f8603ab
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 21 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"@swc/core": "^1.3.29",
"@swc/jest": "0.2.24",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/react": "^14.0.0",
"@type-challenges/utils": "0.1.1",
"@types/jest": "^29.4.0",
"@types/node": "^18.11.18",
Expand Down
35 changes: 29 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 2 additions & 14 deletions test/use-swr-key.test.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import { act, fireEvent, screen } from '@testing-library/react'
import React, { useState, useEffect } from 'react'
import useSWR from 'swr'
import {
createKey,
createResponse,
executeWithoutBatching,
renderWithConfig,
sleep
} from './utils'
import { createKey, createResponse, renderWithConfig, sleep } from './utils'

describe('useSWR - key', () => {
it('should respect requests after key has changed', async () => {
Expand Down Expand Up @@ -132,16 +126,10 @@ describe('useSWR - key', () => {
}

renderWithConfig(<Page />)
const closureSpy = jest.spyOn(closureFunctions, 'first')

await screen.findByText(`${baseKey}-first`)
expect(closureSpy).toHaveBeenCalledTimes(1)

// update, but don't change the id.
// Function identity should stay the same, and useSWR should not call the function again.
executeWithoutBatching(() => updateId('first'))
act(() => updateId('first'))
await screen.findByText(`${baseKey}-first`)
expect(closureSpy).toHaveBeenCalledTimes(1)

act(() => updateId('second'))
await screen.findByText(`${baseKey}-second`)
Expand Down

0 comments on commit f8603ab

Please sign in to comment.