@@ -19,10 +19,10 @@ describe("effect", () => {
1919 const state = reactive ( { a : 1 } ) ;
2020 const spy = jest . fn ( ) ;
2121 effect ( ( ) => spy ( state . a ) ) ;
22- expectSpy ( spy , 1 , [ 1 ] ) ;
22+ expectSpy ( spy , 1 , { args : [ 1 ] } ) ;
2323 state . a = 2 ;
2424 await waitScheduler ( ) ;
25- expectSpy ( spy , 2 , [ 2 ] ) ;
25+ expectSpy ( spy , 2 , { args : [ 2 ] } ) ;
2626 } ) ;
2727 it ( "effect should unsubscribe previous dependencies" , async ( ) => {
2828 const state = reactive ( { a : 1 , b : 10 , c : 100 } ) ;
@@ -34,33 +34,33 @@ describe("effect", () => {
3434 spy ( state . c ) ;
3535 }
3636 } ) ;
37- expectSpy ( spy , 1 , [ 10 ] ) ;
37+ expectSpy ( spy , 1 , { args : [ 10 ] } ) ;
3838 state . b = 20 ;
3939 await waitScheduler ( ) ;
40- expectSpy ( spy , 2 , [ 20 ] ) ;
40+ expectSpy ( spy , 2 , { args : [ 20 ] } ) ;
4141 state . a = 2 ;
4242 await waitScheduler ( ) ;
43- expectSpy ( spy , 3 , [ 100 ] ) ;
43+ expectSpy ( spy , 3 , { args : [ 100 ] } ) ;
4444 state . b = 30 ;
4545 await waitScheduler ( ) ;
46- expectSpy ( spy , 3 , [ 100 ] ) ;
46+ expectSpy ( spy , 3 , { args : [ 100 ] } ) ;
4747 state . c = 200 ;
4848 await waitScheduler ( ) ;
49- expectSpy ( spy , 4 , [ 200 ] ) ;
49+ expectSpy ( spy , 4 , { args : [ 200 ] } ) ;
5050 } ) ;
5151 it ( "effect should not run if dependencies do not change" , async ( ) => {
5252 const state = reactive ( { a : 1 } ) ;
5353 const spy = jest . fn ( ) ;
5454 effect ( ( ) => {
5555 spy ( state . a ) ;
5656 } ) ;
57- expectSpy ( spy , 1 , [ 1 ] ) ;
57+ expectSpy ( spy , 1 , { args : [ 1 ] } ) ;
5858 state . a = 1 ;
5959 await waitScheduler ( ) ;
60- expectSpy ( spy , 1 , [ 1 ] ) ;
60+ expectSpy ( spy , 1 , { args : [ 1 ] } ) ;
6161 state . a = 2 ;
6262 await waitScheduler ( ) ;
63- expectSpy ( spy , 2 , [ 2 ] ) ;
63+ expectSpy ( spy , 2 , { args : [ 2 ] } ) ;
6464 } ) ;
6565 describe ( "nested effects" , ( ) => {
6666 it ( "should track correctly" , async ( ) => {
@@ -75,20 +75,20 @@ describe("effect", () => {
7575 } ) ;
7676 }
7777 } ) ;
78- expectSpy ( spy1 , 1 , [ 1 ] ) ;
79- expectSpy ( spy2 , 1 , [ 10 ] ) ;
78+ expectSpy ( spy1 , 1 , { args : [ 1 ] } ) ;
79+ expectSpy ( spy2 , 1 , { args : [ 10 ] } ) ;
8080 state . b = 20 ;
8181 await waitScheduler ( ) ;
82- expectSpy ( spy1 , 1 , [ 1 ] ) ;
83- expectSpy ( spy2 , 2 , [ 20 ] ) ;
82+ expectSpy ( spy1 , 1 , { args : [ 1 ] } ) ;
83+ expectSpy ( spy2 , 2 , { args : [ 20 ] } ) ;
8484 state . a = 2 ;
8585 await waitScheduler ( ) ;
86- expectSpy ( spy1 , 2 , [ 2 ] ) ;
87- expectSpy ( spy2 , 2 , [ 20 ] ) ;
86+ expectSpy ( spy1 , 2 , { args : [ 2 ] } ) ;
87+ expectSpy ( spy2 , 2 , { args : [ 20 ] } ) ;
8888 state . b = 30 ;
8989 await waitScheduler ( ) ;
90- expectSpy ( spy1 , 2 , [ 2 ] ) ;
91- expectSpy ( spy2 , 2 , [ 20 ] ) ;
90+ expectSpy ( spy1 , 2 , { args : [ 2 ] } ) ;
91+ expectSpy ( spy2 , 2 , { args : [ 20 ] } ) ;
9292 } ) ;
9393 } ) ;
9494 describe ( "unsubscribe" , ( ) => {
@@ -98,14 +98,14 @@ describe("effect", () => {
9898 const unsubscribe = effect ( ( ) => {
9999 spy ( state . a ) ;
100100 } ) ;
101- expectSpy ( spy , 1 , [ 1 ] ) ;
101+ expectSpy ( spy , 1 , { args : [ 1 ] } ) ;
102102 state . a = 2 ;
103103 await waitScheduler ( ) ;
104- expectSpy ( spy , 2 , [ 2 ] ) ;
104+ expectSpy ( spy , 2 , { args : [ 2 ] } ) ;
105105 unsubscribe ( ) ;
106106 state . a = 3 ;
107107 await waitScheduler ( ) ;
108- expectSpy ( spy , 2 , [ 2 ] ) ;
108+ expectSpy ( spy , 2 , { args : [ 2 ] } ) ;
109109 } ) ;
110110 it ( "effect should call cleanup function" , async ( ) => {
111111 const state = reactive ( { a : 1 } ) ;
@@ -115,15 +115,15 @@ describe("effect", () => {
115115 spy ( state . a ) ;
116116 return cleanup ;
117117 } ) ;
118- expectSpy ( spy , 1 , [ 1 ] ) ;
118+ expectSpy ( spy , 1 , { args : [ 1 ] } ) ;
119119 expect ( cleanup ) . toHaveBeenCalledTimes ( 0 ) ;
120120 state . a = 2 ;
121121 await waitScheduler ( ) ;
122- expectSpy ( spy , 2 , [ 2 ] ) ;
122+ expectSpy ( spy , 2 , { args : [ 2 ] } ) ;
123123 expect ( cleanup ) . toHaveBeenCalledTimes ( 1 ) ;
124124 state . a = 3 ;
125125 await waitScheduler ( ) ;
126- expectSpy ( spy , 3 , [ 3 ] ) ;
126+ expectSpy ( spy , 3 , { args : [ 3 ] } ) ;
127127 expect ( cleanup ) . toHaveBeenCalledTimes ( 2 ) ;
128128 } ) ;
129129 it ( "should call cleanup when unsubscribing nested effects" , async ( ) => {
@@ -148,34 +148,34 @@ describe("effect", () => {
148148 } ) ;
149149 return cleanup1 ;
150150 } ) ;
151- expectSpy ( spy1 , 1 , [ 1 ] ) ;
152- expectSpy ( spy2 , 1 , [ 10 ] ) ;
153- expectSpy ( spy3 , 1 , [ 100 ] ) ;
151+ expectSpy ( spy1 , 1 , { args : [ 1 ] } ) ;
152+ expectSpy ( spy2 , 1 , { args : [ 10 ] } ) ;
153+ expectSpy ( spy3 , 1 , { args : [ 100 ] } ) ;
154154 expect ( cleanup1 ) . toHaveBeenCalledTimes ( 0 ) ;
155155 expect ( cleanup2 ) . toHaveBeenCalledTimes ( 0 ) ;
156156 expect ( cleanup3 ) . toHaveBeenCalledTimes ( 0 ) ;
157157 state . b = 20 ;
158158 await waitScheduler ( ) ;
159- expectSpy ( spy1 , 1 , [ 1 ] ) ;
160- expectSpy ( spy2 , 2 , [ 20 ] ) ;
161- expectSpy ( spy3 , 1 , [ 100 ] ) ;
159+ expectSpy ( spy1 , 1 , { args : [ 1 ] } ) ;
160+ expectSpy ( spy2 , 2 , { args : [ 20 ] } ) ;
161+ expectSpy ( spy3 , 1 , { args : [ 100 ] } ) ;
162162 expect ( cleanup1 ) . toHaveBeenCalledTimes ( 0 ) ;
163163 expect ( cleanup2 ) . toHaveBeenCalledTimes ( 1 ) ;
164164 expect ( cleanup3 ) . toHaveBeenCalledTimes ( 0 ) ;
165165 ( global as any ) . d = true ;
166166 state . a = 2 ;
167167 await waitScheduler ( ) ;
168- expectSpy ( spy1 , 2 , [ 2 ] ) ;
169- expectSpy ( spy2 , 2 , [ 20 ] ) ;
170- expectSpy ( spy3 , 2 , [ 100 ] ) ;
168+ expectSpy ( spy1 , 2 , { args : [ 2 ] } ) ;
169+ expectSpy ( spy2 , 2 , { args : [ 20 ] } ) ;
170+ expectSpy ( spy3 , 2 , { args : [ 100 ] } ) ;
171171 expect ( cleanup1 ) . toHaveBeenCalledTimes ( 1 ) ;
172172 expect ( cleanup2 ) . toHaveBeenCalledTimes ( 2 ) ;
173173 expect ( cleanup3 ) . toHaveBeenCalledTimes ( 1 ) ;
174174 state . b = 30 ;
175175 await waitScheduler ( ) ;
176- expectSpy ( spy1 , 2 , [ 2 ] ) ;
177- expectSpy ( spy2 , 2 , [ 20 ] ) ;
178- expectSpy ( spy3 , 2 , [ 100 ] ) ;
176+ expectSpy ( spy1 , 2 , { args : [ 2 ] } ) ;
177+ expectSpy ( spy2 , 2 , { args : [ 20 ] } ) ;
178+ expectSpy ( spy3 , 2 , { args : [ 100 ] } ) ;
179179 expect ( cleanup1 ) . toHaveBeenCalledTimes ( 1 ) ;
180180 expect ( cleanup2 ) . toHaveBeenCalledTimes ( 2 ) ;
181181 expect ( cleanup3 ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -187,9 +187,9 @@ describe("effect", () => {
187187 state . b = 40 ;
188188 state . c = 400 ;
189189 await waitScheduler ( ) ;
190- expectSpy ( spy1 , 2 , [ 2 ] ) ;
191- expectSpy ( spy2 , 2 , [ 20 ] ) ;
192- expectSpy ( spy3 , 2 , [ 100 ] ) ;
190+ expectSpy ( spy1 , 2 , { args : [ 2 ] } ) ;
191+ expectSpy ( spy2 , 2 , { args : [ 20 ] } ) ;
192+ expectSpy ( spy3 , 2 , { args : [ 100 ] } ) ;
193193 expect ( cleanup1 ) . toHaveBeenCalledTimes ( 2 ) ;
194194 expect ( cleanup2 ) . toHaveBeenCalledTimes ( 2 ) ;
195195 expect ( cleanup3 ) . toHaveBeenCalledTimes ( 2 ) ;
0 commit comments