Skip to content

Commit

Permalink
add a failing test case
Browse files Browse the repository at this point in the history
  • Loading branch information
titoBouzout committed Sep 13, 2024
1 parent e4b2c66 commit ea99dd6
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions packages/solid/store/test/modifiers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,32 @@ describe("setState with reconcile", () => {
setStore(reconcile({ value: { q: "aa" } }));
expect(store.value).toEqual({ q: "aa" });
});
test("reconciles an object with an array", () => {
const [store, setStore] = createStore<{ value: {} | [] }>({
value: { foo: "bar" }
});

const value = [0, 1, 2];
setStore("value", reconcile(value));

expect(Array.isArray(store.value)).toBe(true);
expect(store).toEqual({
value: [0, 1, 2]
});
});

test("reconciles an array with an object", () => {
const [store, setStore] = createStore<{ value: {} | [] }>({
value: [0, 1, 2]
});

const value = { foo: "bar" };
setStore("value", reconcile(value));
expect(Array.isArray(store.value)).toBe(false);
expect(store).toEqual({
value: { foo: "bar" }
});
});
});

describe("setState with produce", () => {
Expand Down

0 comments on commit ea99dd6

Please sign in to comment.