File tree 1 file changed +26
-0
lines changed
packages/solid/store/test
1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -156,6 +156,32 @@ describe("setState with reconcile", () => {
156
156
setStore ( reconcile ( { value : { q : "aa" } } ) ) ;
157
157
expect ( store . value ) . toEqual ( { q : "aa" } ) ;
158
158
} ) ;
159
+ test ( "reconciles an object with an array" , ( ) => {
160
+ const [ store , setStore ] = createStore < { value : { } | [ ] } > ( {
161
+ value : { foo : "bar" }
162
+ } ) ;
163
+
164
+ const value = [ 0 , 1 , 2 ] ;
165
+ setStore ( "value" , reconcile ( value ) ) ;
166
+
167
+ expect ( Array . isArray ( store . value ) ) . toBe ( true ) ;
168
+ expect ( store ) . toEqual ( {
169
+ value : [ 0 , 1 , 2 ]
170
+ } ) ;
171
+ } ) ;
172
+
173
+ test ( "reconciles an array with an object" , ( ) => {
174
+ const [ store , setStore ] = createStore < { value : { } | [ ] } > ( {
175
+ value : [ 0 , 1 , 2 ]
176
+ } ) ;
177
+
178
+ const value = { foo : "bar" } ;
179
+ setStore ( "value" , reconcile ( value ) ) ;
180
+ expect ( Array . isArray ( store . value ) ) . toBe ( false ) ;
181
+ expect ( store ) . toEqual ( {
182
+ value : { foo : "bar" }
183
+ } ) ;
184
+ } ) ;
159
185
} ) ;
160
186
161
187
describe ( "setState with produce" , ( ) => {
You can’t perform that action at this time.
0 commit comments