Skip to content

Commit

Permalink
ensure inertness in test for createMutable
Browse files Browse the repository at this point in the history
  • Loading branch information
ryansolid committed Jan 23, 2024
1 parent 5f6a519 commit d6b9418
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion packages/solid/store/test/mutableWithClass.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createRoot } from "../../src";
import { createEffect, createRoot } from "../../src";
import { createMutable } from "../src";

describe("Class Operator test", () => {
Expand All @@ -17,23 +17,39 @@ describe("Class Operator test", () => {
child = new D();
}
let m: any;
let count = 0,
childCount = 0;
const increment = () => {
m.a++;
m.child.f++;
};

createRoot(() => {
m = createMutable(new A());
createEffect(() => {
m.b;
count++;
});
createEffect(() => {
m.child.f;
childCount++;
});
increment();
});

expect(m.b).toBe(8);
expect(m.child.e).toBe(8);
expect(count).toBe(1);
expect(childCount).toBe(1);
increment();
expect(m.b).toBe(12);
expect(m.child.e).toBe(12);
expect(count).toBe(2);
expect(childCount).toBe(1);
increment();
expect(m.b).toBe(16);
expect(m.child.e).toBe(16);
expect(count).toBe(3);
expect(childCount).toBe(1);
});
});

0 comments on commit d6b9418

Please sign in to comment.