File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed
packages/svelte/src/reactivity Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -106,3 +106,50 @@ test('set.forEach()', () => {
106
106
107
107
cleanup ( ) ;
108
108
} ) ;
109
+
110
+ test ( 'not invoking reactivity when value is not in the set after changes' , ( ) => {
111
+ const set = new ReactiveSet ( [ 1 , 2 ] ) ;
112
+
113
+ const log : any = [ ] ;
114
+
115
+ const cleanup = effect_root ( ( ) => {
116
+ render_effect ( ( ) => {
117
+ log . push ( 'has 1' , set . has ( 1 ) ) ;
118
+ } ) ;
119
+
120
+ render_effect ( ( ) => {
121
+ log . push ( 'has 2' , set . has ( 2 ) ) ;
122
+ } ) ;
123
+
124
+ render_effect ( ( ) => {
125
+ log . push ( 'has 3' , set . has ( 3 ) ) ;
126
+ } ) ;
127
+ } ) ;
128
+
129
+ flushSync ( ( ) => {
130
+ set . delete ( 2 ) ;
131
+ } ) ;
132
+
133
+ flushSync ( ( ) => {
134
+ set . add ( 2 ) ;
135
+ } ) ;
136
+
137
+ assert . deepEqual ( log , [
138
+ 'has 1' ,
139
+ true ,
140
+ 'has 2' ,
141
+ true ,
142
+ 'has 3' ,
143
+ false ,
144
+ 'has 2' ,
145
+ false ,
146
+ 'has 2' ,
147
+ true
148
+ ] ) ;
149
+
150
+ cleanup ( ) ;
151
+ } ) ;
152
+
153
+ test ( 'Set.instanceOf' , ( ) => {
154
+ assert . equal ( new ReactiveSet ( ) instanceof Set , true ) ;
155
+ } ) ;
You can’t perform that action at this time.
0 commit comments