Skip to content

Commit 7ec0294

Browse files
committed
add test
1 parent 1e92922 commit 7ec0294

File tree

1 file changed

+33
-0
lines changed
  • packages/svelte/tests/signals

1 file changed

+33
-0
lines changed

packages/svelte/tests/signals/test.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,4 +781,37 @@ describe('signals', () => {
781781
assert.equal($.get(count), 0n);
782782
};
783783
});
784+
785+
test('unowned deriveds correctly re-attach to their source', () => {
786+
const log: any[] = [];
787+
788+
return () => {
789+
const a = state(0);
790+
const b = state(0);
791+
const c = derived(() => {
792+
$.get(a);
793+
return $.get(b)
794+
});
795+
796+
$.get(c);
797+
798+
set(a, 1);
799+
800+
const destroy = effect_root(() => {
801+
render_effect(() => {
802+
log.push($.get(c));
803+
});
804+
});
805+
806+
assert.deepEqual(log, [0]);
807+
808+
set(b, 1);
809+
810+
flushSync();
811+
812+
assert.deepEqual(log, [0, 1]);
813+
814+
destroy();
815+
};
816+
});
784817
});

0 commit comments

Comments
 (0)