mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] re-introduce tests
This commit is contained in:
committed by
Géry Debongnie
parent
ee64de8b3f
commit
abe3748825
@@ -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", () => {
|
||||
|
||||
Reference in New Issue
Block a user