Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: rename from waitForDedupingInterval to waitForNextTick #960

Merged
merged 1 commit into from
Feb 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions test/use-swr-focus.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { useState } from 'react'
import useSWR from '../src'
import { sleep } from './utils'

const waitForDedupingInterval = async () => await act(() => sleep(1))
const waitForNextTick = async () => await act(() => sleep(1))

describe('useSWR - focus', () => {
it('should revalidate on focus by default', async () => {
Expand All @@ -22,7 +22,7 @@ describe('useSWR - focus', () => {
// mount
await screen.findByText('data: 0')

await waitForDedupingInterval()
await waitForNextTick()
// trigger revalidation
fireEvent.focus(window)
await screen.findByText('data: 1')
Expand All @@ -45,7 +45,7 @@ describe('useSWR - focus', () => {
// mount
await screen.findByText('data: 0')

await waitForDedupingInterval()
await waitForNextTick()
// trigger revalidation
fireEvent.focus(window)
// should not be revalidated
Expand All @@ -70,7 +70,7 @@ describe('useSWR - focus', () => {
// mount
await screen.findByText('data: 0')

await waitForDedupingInterval()
await waitForNextTick()
// trigger revalidation
fireEvent.focus(window)
// data should not change
Expand All @@ -83,13 +83,13 @@ describe('useSWR - focus', () => {
// data should update
await screen.findByText('data: 1')

await waitForDedupingInterval()
await waitForNextTick()
// trigger revalidation
fireEvent.focus(window)
// data should update
await screen.findByText('data: 2')

await waitForDedupingInterval()
await waitForNextTick()
// change revalidateOnFocus to false
fireEvent.click(container.firstElementChild)
// trigger revalidation
Expand Down Expand Up @@ -120,7 +120,7 @@ describe('useSWR - focus', () => {
// mount
await screen.findByText('data: 0')

await waitForDedupingInterval()
await waitForNextTick()
// trigger revalidation
fireEvent.focus(window)
// still in throttling interval
Expand Down Expand Up @@ -159,7 +159,7 @@ describe('useSWR - focus', () => {
// mount
await screen.findByText('data: 0')

await waitForDedupingInterval()
await waitForNextTick()
// trigger revalidation
fireEvent.focus(window)
// wait for throttle interval
Expand All @@ -168,7 +168,7 @@ describe('useSWR - focus', () => {
fireEvent.focus(window)
await screen.findByText('data: 2')

await waitForDedupingInterval()
await waitForNextTick()
// increase focusThrottleInterval
fireEvent.click(container.firstElementChild)
// wait for throttle interval
Expand Down
2 changes: 1 addition & 1 deletion test/use-swr-local-mutation.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ describe('useSWR - local mutation', () => {
//mount
await screen.findByText('data: 0')

// wait for dedupingInterval
// wait for the next tick
await act(() => sleep(1))
await act(() => {
// mutate and revalidate
Expand Down