[FIX] re-introduce tests

This commit is contained in:
Lucas Perais (lpe)
2021-10-18 17:52:25 +02:00
committed by Géry Debongnie
parent ee64de8b3f
commit abe3748825
17 changed files with 616 additions and 79 deletions
+44
View File
@@ -447,6 +447,50 @@ describe("observe", () => {
obj2.key = 3;
expect(n).toBe(1);
});
test.skip("call callback when state is changed", async () => {
/* const observer = new Observer();
observer.notifyCB = jest.fn();
const obj: any = observer.observe({ a: 1, b: { c: 2 }, d: [{ e: 3 }], f: 4 });
expect(observer.notifyCB).toBeCalledTimes(0);
obj.a = 2;
await nextMicroTick();
expect(observer.notifyCB).toBeCalledTimes(1);
obj.b.c = 3;
await nextMicroTick();
expect(observer.notifyCB).toBeCalledTimes(2);
obj.d[0].e = 5;
await nextMicroTick();
expect(observer.notifyCB).toBeCalledTimes(3);
obj.a = 111;
obj.f = 222;
await nextMicroTick();
expect(observer.notifyCB).toBeCalledTimes(5);*/
});
test.skip("throw error when state is mutated in object if allowMutation=false", async () => {
/*const observer = new Observer();
observer.allowMutations = false;
const obj: any = observer.observe({ a: 1 });
expect(() => {
obj.a = 2;
}).toThrow('Observed state cannot be changed here! (key: "a", val: "2")');*/
});
test.skip("throw error when state is mutated in array if allowMutation=false", async () => {
/* const observer = new Observer();
observer.allowMutations = false;
const obj: any = observer.observe({ a: [1] });
expect(() => {
obj.a.push(2);
}).toThrow('Observed state cannot be changed here! (key: "1", val: "2")');*/
});
});
describe("unobserve", () => {