@@ -141,6 +141,7 @@ describe('useMutableSource', () => {
141
141
142
142
beforeEach ( loadModules ) ;
143
143
144
+ // @gate enableUseMutableSource
144
145
it ( 'should subscribe to a source and schedule updates when it changes' , ( ) => {
145
146
const source = createSource ( 'one' ) ;
146
147
const mutableSource = createMutableSource ( source , param => param . version ) ;
@@ -208,6 +209,7 @@ describe('useMutableSource', () => {
208
209
} ) ;
209
210
} ) ;
210
211
212
+ // @gate enableUseMutableSource
211
213
it ( 'should restart work if a new source is mutated during render' , ( ) => {
212
214
const source = createSource ( 'one' ) ;
213
215
const mutableSource = createMutableSource ( source , param => param . version ) ;
@@ -263,6 +265,7 @@ describe('useMutableSource', () => {
263
265
} ) ;
264
266
} ) ;
265
267
268
+ // @gate enableUseMutableSource
266
269
it ( 'should schedule an update if a new source is mutated between render and commit (subscription)' , ( ) => {
267
270
const source = createSource ( 'one' ) ;
268
271
const mutableSource = createMutableSource ( source , param => param . version ) ;
@@ -302,6 +305,7 @@ describe('useMutableSource', () => {
302
305
} ) ;
303
306
} ) ;
304
307
308
+ // @gate enableUseMutableSource
305
309
it ( 'should unsubscribe and resubscribe if a new source is used' , ( ) => {
306
310
const sourceA = createSource ( 'a-one' ) ;
307
311
const mutableSourceA = createMutableSource (
@@ -358,6 +362,7 @@ describe('useMutableSource', () => {
358
362
} ) ;
359
363
} ) ;
360
364
365
+ // @gate enableUseMutableSource
361
366
it ( 'should unsubscribe and resubscribe if a new subscribe function is provided' , ( ) => {
362
367
const source = createSource ( 'a-one' ) ;
363
368
const mutableSource = createMutableSource ( source , param => param . version ) ;
@@ -422,6 +427,7 @@ describe('useMutableSource', () => {
422
427
} ) ;
423
428
} ) ;
424
429
430
+ // @gate enableUseMutableSource
425
431
it ( 'should re-use previously read snapshot value when reading is unsafe' , ( ) => {
426
432
const source = createSource ( 'one' ) ;
427
433
const mutableSource = createMutableSource ( source , param => param . version ) ;
@@ -484,6 +490,7 @@ describe('useMutableSource', () => {
484
490
} ) ;
485
491
} ) ;
486
492
493
+ // @gate enableUseMutableSource
487
494
it ( 'should read from source on newly mounted subtree if no pending updates are scheduled for source' , ( ) => {
488
495
const source = createSource ( 'one' ) ;
489
496
const mutableSource = createMutableSource ( source , param => param . version ) ;
@@ -523,6 +530,7 @@ describe('useMutableSource', () => {
523
530
} ) ;
524
531
} ) ;
525
532
533
+ // @gate enableUseMutableSource
526
534
it ( 'should throw and restart render if source and snapshot are unavailable during an update' , ( ) => {
527
535
const source = createSource ( 'one' ) ;
528
536
const mutableSource = createMutableSource ( source , param => param . version ) ;
@@ -586,6 +594,7 @@ describe('useMutableSource', () => {
586
594
} ) ;
587
595
} ) ;
588
596
597
+ // @gate enableUseMutableSource
589
598
it ( 'should throw and restart render if source and snapshot are unavailable during a sync update' , ( ) => {
590
599
const source = createSource ( 'one' ) ;
591
600
const mutableSource = createMutableSource ( source , param => param . version ) ;
@@ -649,6 +658,7 @@ describe('useMutableSource', () => {
649
658
} ) ;
650
659
} ) ;
651
660
661
+ // @gate enableUseMutableSource
652
662
it ( 'should only update components whose subscriptions fire' , ( ) => {
653
663
const source = createComplexSource ( 'a:one' , 'b:one' ) ;
654
664
const mutableSource = createMutableSource ( source , param => param . version ) ;
@@ -687,6 +697,7 @@ describe('useMutableSource', () => {
687
697
} ) ;
688
698
} ) ;
689
699
700
+ // @gate enableUseMutableSource
690
701
it ( 'should detect tearing in part of the store not yet subscribed to' , ( ) => {
691
702
const source = createComplexSource ( 'a:one' , 'b:one' ) ;
692
703
const mutableSource = createMutableSource ( source , param => param . version ) ;
@@ -779,6 +790,7 @@ describe('useMutableSource', () => {
779
790
} ) ;
780
791
} ) ;
781
792
793
+ // @gate enableUseMutableSource
782
794
it ( 'does not schedule an update for subscriptions that fire with an unchanged snapshot' , ( ) => {
783
795
const MockComponent = jest . fn ( Component ) ;
784
796
@@ -805,6 +817,7 @@ describe('useMutableSource', () => {
805
817
} ) ;
806
818
} ) ;
807
819
820
+ // @gate enableUseMutableSource
808
821
it ( 'should throw and restart if getSnapshot changes between scheduled update and re-render' , ( ) => {
809
822
const source = createSource ( 'one' ) ;
810
823
const mutableSource = createMutableSource ( source , param => param . version ) ;
@@ -845,6 +858,7 @@ describe('useMutableSource', () => {
845
858
} ) ;
846
859
} ) ;
847
860
861
+ // @gate enableUseMutableSource
848
862
it ( 'should recover from a mutation during yield when other work is scheduled' , ( ) => {
849
863
const source = createSource ( 'one' ) ;
850
864
const mutableSource = createMutableSource ( source , param => param . version ) ;
@@ -899,6 +913,7 @@ describe('useMutableSource', () => {
899
913
} ) ;
900
914
} ) ;
901
915
916
+ // @gate enableUseMutableSource
902
917
it ( 'should not throw if the new getSnapshot returns the same snapshot value' , ( ) => {
903
918
const source = createSource ( 'one' ) ;
904
919
const mutableSource = createMutableSource ( source , param => param . version ) ;
@@ -953,6 +968,7 @@ describe('useMutableSource', () => {
953
968
} ) ;
954
969
} ) ;
955
970
971
+ // @gate enableUseMutableSource
956
972
it ( 'should not throw if getSnapshot changes but the source can be safely read from anyway' , ( ) => {
957
973
const source = createSource ( 'one' ) ;
958
974
const mutableSource = createMutableSource ( source , param => param . version ) ;
@@ -992,6 +1008,7 @@ describe('useMutableSource', () => {
992
1008
} ) ;
993
1009
} ) ;
994
1010
1011
+ // @gate enableUseMutableSource
995
1012
it ( 'should still schedule an update if an eager selector throws after a mutation' , ( ) => {
996
1013
const source = createSource ( {
997
1014
friends : [
@@ -1058,6 +1075,7 @@ describe('useMutableSource', () => {
1058
1075
} ) ;
1059
1076
} ) ;
1060
1077
1078
+ // @gate enableUseMutableSource
1061
1079
it ( 'should not warn about updates that fire between unmount and passive unsubscribe' , ( ) => {
1062
1080
const source = createSource ( 'one' ) ;
1063
1081
const mutableSource = createMutableSource ( source , param => param . version ) ;
@@ -1094,6 +1112,7 @@ describe('useMutableSource', () => {
1094
1112
} ) ;
1095
1113
} ) ;
1096
1114
1115
+ // @gate enableUseMutableSource
1097
1116
it ( 'should support inline selectors and updates that are processed after selector change' , async ( ) => {
1098
1117
const source = createSource ( {
1099
1118
a : 'initial' ,
@@ -1138,6 +1157,7 @@ describe('useMutableSource', () => {
1138
1157
expect ( root ) . toMatchRenderedOutput ( 'Another update' ) ;
1139
1158
} ) ;
1140
1159
1160
+ // @gate enableUseMutableSource
1141
1161
it ( 'should clear the update queue when getSnapshot changes with pending lower priority updates' , async ( ) => {
1142
1162
const source = createSource ( {
1143
1163
a : 'initial' ,
@@ -1194,6 +1214,7 @@ describe('useMutableSource', () => {
1194
1214
expect ( root ) . toMatchRenderedOutput ( 'B: Update' ) ;
1195
1215
} ) ;
1196
1216
1217
+ // @gate enableUseMutableSource
1197
1218
it ( 'should clear the update queue when source changes with pending lower priority updates' , async ( ) => {
1198
1219
const sourceA = createSource ( 'initial' ) ;
1199
1220
const sourceB = createSource ( 'initial' ) ;
@@ -1238,6 +1259,7 @@ describe('useMutableSource', () => {
1238
1259
expect ( root ) . toMatchRenderedOutput ( 'B: Update' ) ;
1239
1260
} ) ;
1240
1261
1262
+ // @gate enableUseMutableSource
1241
1263
it ( 'should always treat reading as potentially unsafe when getSnapshot changes between renders' , async ( ) => {
1242
1264
const source = createSource ( {
1243
1265
a : 'foo' ,
@@ -1327,6 +1349,7 @@ describe('useMutableSource', () => {
1327
1349
expect ( Scheduler ) . toHaveYielded ( [ 'x: bar, y: bar' ] ) ;
1328
1350
} ) ;
1329
1351
1352
+ // @gate enableUseMutableSource
1330
1353
it ( 'getSnapshot changes and then source is mutated in between paint and passive effect phase' , async ( ) => {
1331
1354
const source = createSource ( {
1332
1355
a : 'foo' ,
@@ -1385,6 +1408,7 @@ describe('useMutableSource', () => {
1385
1408
expect ( root ) . toMatchRenderedOutput ( 'baz' ) ;
1386
1409
} ) ;
1387
1410
1411
+ // @gate enableUseMutableSource
1388
1412
it ( 'getSnapshot changes and then source is mutated in between paint and passive effect phase, case 2' , async ( ) => {
1389
1413
const source = createSource ( {
1390
1414
a : 'a0' ,
@@ -1455,6 +1479,7 @@ describe('useMutableSource', () => {
1455
1479
expect ( root . getChildrenAsJSX ( ) ) . toEqual ( 'first: a1, second: a1' ) ;
1456
1480
} ) ;
1457
1481
1482
+ // @gate enableUseMutableSource
1458
1483
it (
1459
1484
'if source is mutated after initial read but before subscription is set ' +
1460
1485
'up, should still entangle all pending mutations even if snapshot of ' +
@@ -1559,6 +1584,7 @@ describe('useMutableSource', () => {
1559
1584
} ,
1560
1585
) ;
1561
1586
1587
+ // @gate enableUseMutableSource
1562
1588
it ( 'warns about functions being used as snapshot values' , async ( ) => {
1563
1589
const source = createSource ( ( ) => 'a' ) ;
1564
1590
const mutableSource = createMutableSource ( source , param => param . version ) ;
@@ -1586,6 +1612,7 @@ describe('useMutableSource', () => {
1586
1612
expect ( root ) . toMatchRenderedOutput ( 'a' ) ;
1587
1613
} ) ;
1588
1614
1615
+ // @gate enableUseMutableSource
1589
1616
it ( 'getSnapshot changes and then source is mutated during interleaved event' , async ( ) => {
1590
1617
const { useEffect} = React ;
1591
1618
@@ -1710,6 +1737,7 @@ describe('useMutableSource', () => {
1710
1737
} ) ;
1711
1738
} ) ;
1712
1739
1740
+ // @gate enableUseMutableSource
1713
1741
it ( 'should not tear with newly mounted component when updates were scheduled at a lower priority' , async ( ) => {
1714
1742
const source = createSource ( 'one' ) ;
1715
1743
const mutableSource = createMutableSource ( source , param => param . version ) ;
@@ -1789,6 +1817,7 @@ describe('useMutableSource', () => {
1789
1817
1790
1818
if ( __DEV__ ) {
1791
1819
describe ( 'dev warnings' , ( ) => {
1820
+ // @gate enableUseMutableSource
1792
1821
it ( 'should warn if the subscribe function does not return an unsubscribe function' , ( ) => {
1793
1822
const source = createSource ( 'one' ) ;
1794
1823
const mutableSource = createMutableSource (
@@ -1814,6 +1843,7 @@ describe('useMutableSource', () => {
1814
1843
) ;
1815
1844
} ) ;
1816
1845
1846
+ // @gate enableUseMutableSource
1817
1847
it ( 'should error if multiple renderers of the same type use a mutable source at the same time' , ( ) => {
1818
1848
const source = createSource ( 'one' ) ;
1819
1849
const mutableSource = createMutableSource (
@@ -1894,6 +1924,7 @@ describe('useMutableSource', () => {
1894
1924
} ) ;
1895
1925
} ) ;
1896
1926
1927
+ // @gate enableUseMutableSource
1897
1928
it ( 'should error if multiple renderers of the same type use a mutable source at the same time with mutation between' , ( ) => {
1898
1929
const source = createSource ( 'one' ) ;
1899
1930
const mutableSource = createMutableSource (
0 commit comments