-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
test("should safe correct reactions order for changing depth without modification", () => {
const spy = jest.fn();
const a = mut(0);
const b = mut(0);
const m0 = comp(() => {
return !b.val ? a.val : k0.val;
});
const k0 = comp(() => {
return !b.val ? m0.val : a.val;
});
const m = comp(() => m0.val);
const k = comp(() => k0.val);
let i = 0;
run(() => (k.val, spy('k', i++)));
run(() => (m.val, spy('m', i++)));
expect(spy).toHaveBeenNthCalledWith(1, 'k', 0);
expect(spy).toHaveBeenNthCalledWith(2, 'm', 1);
expect(spy).toBeCalledTimes(2);
spy.mockReset();
a.val = 1;
expect(spy).toHaveBeenNthCalledWith(1, 'm', 2);
expect(spy).toHaveBeenNthCalledWith(2, 'k', 3);
expect(spy).toBeCalledTimes(2);
spy.mockReset();
// switch
b.val = 1;
expect(spy).toBeCalledTimes(0);
// check
a.val = 2;
// TODO: check failed (m:4, k:5)
// expect(spy).toHaveBeenNthCalledWith(1, 'k', 4);
// expect(spy).toHaveBeenNthCalledWith(2, 'm', 5);
expect(spy).toBeCalledTimes(2);
spy.mockReset();
});
d80be9c#diff-a9b84960a146958d9aecb5cbe3fccdf262c40fe07bddbb659f63d8a7766ed3a5R203-R245
Metadata
Metadata
Assignees
Labels
No labels