File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
packages/svelte/tests/signals Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -144,6 +144,38 @@ describe('signals', () => {
144
144
} ;
145
145
} ) ;
146
146
147
+ test ( 'state reset' , ( ) => {
148
+ const log : number [ ] = [ ] ;
149
+
150
+ let count = source ( 0 ) ;
151
+ let double = derived ( ( ) => $ . get ( count ) * 2 ) ;
152
+
153
+ effect ( ( ) => {
154
+ log . push ( $ . get ( double ) ) ;
155
+ } ) ;
156
+
157
+ return ( ) => {
158
+ flushSync ( ) ;
159
+ log . length = 0 ;
160
+
161
+ set ( count , 1 ) ;
162
+ set ( count , 0 ) ;
163
+
164
+ flushSync ( ) ;
165
+
166
+ assert . deepEqual ( log , [ ] ) ;
167
+
168
+ set ( count , 1 ) ;
169
+ $ . get ( double ) ;
170
+ set ( count , 0 ) ;
171
+
172
+ flushSync ( ) ;
173
+
174
+ // TODO: in an ideal world, the effect wouldn't fire here
175
+ assert . deepEqual ( log , [ 0 ] ) ;
176
+ } ;
177
+ } ) ;
178
+
147
179
test ( 'https://perf.js.hyoo.ru/#!bench=9h2as6_u0mfnn' , ( ) => {
148
180
let res : number [ ] = [ ] ;
149
181
You can’t perform that action at this time.
0 commit comments