@@ -543,41 +543,41 @@ describe('useSWR - refresh', () => {
543
543
return new Promise ( res => setTimeout ( res , 150 ) )
544
544
} )
545
545
expect ( container . firstChild . textContent ) . toMatchInlineSnapshot ( `"count: 2"` )
546
+ fireEvent . click ( container . firstElementChild )
546
547
await act ( ( ) => {
547
- fireEvent . click ( container . firstElementChild )
548
548
// it will clear 200ms timer and setup a new 300ms timer
549
549
return new Promise ( res => setTimeout ( res , 200 ) )
550
550
} )
551
- expect ( container . firstChild . textContent ) . toMatchInlineSnapshot ( `"count: 2 "` )
551
+ expect ( container . firstChild . textContent ) . toMatchInlineSnapshot ( `"count: 3 "` )
552
552
await act ( ( ) => {
553
553
return new Promise ( res => setTimeout ( res , 110 ) )
554
554
} )
555
- expect ( container . firstChild . textContent ) . toMatchInlineSnapshot ( `"count: 3 "` )
555
+ expect ( container . firstChild . textContent ) . toMatchInlineSnapshot ( `"count: 4 "` )
556
556
await act ( ( ) => {
557
557
// wait for new 300ms timer
558
558
return new Promise ( res => setTimeout ( res , 310 ) )
559
559
} )
560
- expect ( container . firstChild . textContent ) . toMatchInlineSnapshot ( `"count: 4"` )
560
+ expect ( container . firstChild . textContent ) . toMatchInlineSnapshot ( `"count: 5"` )
561
+ fireEvent . click ( container . firstElementChild )
561
562
await act ( ( ) => {
562
- fireEvent . click ( container . firstElementChild )
563
563
// it will clear 300ms timer and setup a new 400ms timer
564
564
return new Promise ( res => setTimeout ( res , 300 ) )
565
565
} )
566
- expect ( container . firstChild . textContent ) . toMatchInlineSnapshot ( `"count: 4 "` )
566
+ expect ( container . firstChild . textContent ) . toMatchInlineSnapshot ( `"count: 6 "` )
567
567
await act ( ( ) => {
568
568
return new Promise ( res => setTimeout ( res , 110 ) )
569
569
} )
570
- expect ( container . firstChild . textContent ) . toMatchInlineSnapshot ( `"count: 5"` )
570
+ expect ( container . firstChild . textContent ) . toMatchInlineSnapshot ( `"count: 7"` )
571
+ fireEvent . click ( container . firstElementChild )
571
572
await act ( ( ) => {
572
- fireEvent . click ( container . firstElementChild )
573
573
// it will clear 400ms timer and stop
574
574
return new Promise ( res => setTimeout ( res , 110 ) )
575
575
} )
576
- expect ( container . firstChild . textContent ) . toMatchInlineSnapshot ( `"count: 5 "` )
576
+ expect ( container . firstChild . textContent ) . toMatchInlineSnapshot ( `"count: 7 "` )
577
577
await act ( ( ) => {
578
578
return new Promise ( res => setTimeout ( res , 110 ) )
579
579
} )
580
- expect ( container . firstChild . textContent ) . toMatchInlineSnapshot ( `"count: 5 "` )
580
+ expect ( container . firstChild . textContent ) . toMatchInlineSnapshot ( `"count: 7 "` )
581
581
} )
582
582
583
583
it ( 'should update data upon interval changes -- changes happened during revalidate' , async ( ) => {
0 commit comments