Skip to content

Commit 5ba5309

Browse files
author
Brian Vaughn
committed
Simplified tearing test case slightly
1 parent 9815c0c commit 5ba5309

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

packages/use-subscription/src/__tests__/useSubscription-test.internal.js

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -602,28 +602,22 @@ describe('useSubscription', () => {
602602
// This update will be eagerly evaluated,
603603
// so the tearing case this test is guarding against would not happen.
604604
mutate('B');
605-
expect(Scheduler).toFlushAndYieldThrough(['render:first:B']);
606-
mutate('C');
607-
expect(Scheduler).toFlushAndYield([
608-
'render:second:B',
609-
'render:first:C',
610-
'render:second:C',
611-
]);
605+
expect(Scheduler).toFlushAndYield(['render:first:B', 'render:second:B']);
612606

613607
// No more pending updates
614608
jest.runAllTimers();
615609

616-
// Partial update "C" -> "D"
617-
// Interrupt with a second mutation "D" -> "E".
610+
// Partial update "B" -> "C"
611+
// Interrupt with a second mutation "C" -> "D".
618612
// This update will not be eagerly evaluated,
619613
// but useSubscription() should eagerly close over the updated value to avoid tearing.
614+
mutate('C');
615+
expect(Scheduler).toFlushAndYieldThrough(['render:first:C']);
620616
mutate('D');
621-
expect(Scheduler).toFlushAndYieldThrough(['render:first:D']);
622-
mutate('E');
623617
expect(Scheduler).toFlushAndYield([
618+
'render:second:C',
619+
'render:first:D',
624620
'render:second:D',
625-
'render:first:E',
626-
'render:second:E',
627621
]);
628622

629623
// No more pending updates

0 commit comments

Comments
 (0)