Skip to content

Commit

Permalink
Nested property tracking UT
Browse files Browse the repository at this point in the history
  • Loading branch information
cesarParra committed Nov 21, 2024
1 parent 5253d36 commit 111a45c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/lwc/signals/__tests__/computed.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ describe("computed values", () => {
expect(computed.value).toBe(2);
});

test("are recomputed when a nested property of the source object changes when the signal is being tracked", () => {
const signal = $signal({ a: { b: 0 } }, { track: true });
const computed = $computed(() => signal.value.a.b * 2);
expect(computed.value).toBe(0);

signal.value.a.b = 1;

expect(computed.value).toBe(2);
});

test("are not recomputed when the source is an object and has changes when the signal is not being tracked", () => {
const signal = $signal({ a: 0 });
const computed = $computed(() => signal.value.a * 2);
Expand Down

0 comments on commit 111a45c

Please sign in to comment.