File tree 1 file changed +25
-0
lines changed
packages/reactivity/__tests__
1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -821,6 +821,31 @@ describe('reactivity/effect', () => {
821
821
expect ( dummy ) . toBe ( 3 )
822
822
} )
823
823
824
+ it ( 'stop with multiple dependencies' , ( ) => {
825
+ let dummy1 , dummy2
826
+ const obj1 = reactive ( { prop : 1 } )
827
+ const obj2 = reactive ( { prop : 1 } )
828
+ const runner = effect ( ( ) => {
829
+ dummy1 = obj1 . prop
830
+ dummy2 = obj2 . prop
831
+ } )
832
+
833
+ obj1 . prop = 2
834
+ expect ( dummy1 ) . toBe ( 2 )
835
+
836
+ obj2 . prop = 3
837
+ expect ( dummy2 ) . toBe ( 3 )
838
+
839
+ stop ( runner )
840
+
841
+ obj1 . prop = 4
842
+ obj2 . prop = 5
843
+
844
+ // Check that both dependencies have been cleared
845
+ expect ( dummy1 ) . toBe ( 2 )
846
+ expect ( dummy2 ) . toBe ( 3 )
847
+ } )
848
+
824
849
// #5707
825
850
// when an effect completes its run, it should clear the tracking bits of
826
851
// its tracked deps. However, if the effect stops itself, the deps list is
You can’t perform that action at this time.
0 commit comments