chore: add regression test for $effect.pre rerun after flushSync
Closes #18209
This commit is contained in:
1 parent
a371ed2c38
commit
84c8d09f31
1 file changed
+22
@@ -1151,6 +1151,28 @@ describe('signals', () => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('pre effect that writes its own dependency reruns on every flushSync', () => {
|
||||||
|
const destroy = effect_root(() => {
|
||||||
|
const control = state('A');
|
||||||
|
const value = state(0);
|
||||||
|
|
||||||
|
user_pre_effect(() => {
|
||||||
|
$.get(value);
|
||||||
|
set(value, $.get(control) === 'A' ? 1 : 2);
|
||||||
|
});
|
||||||
|
|
||||||
|
set(control, 'B');
|
||||||
|
flushSync();
|
||||||
|
assert.equal($.get(value), 2);
|
||||||
|
|
||||||
|
set(control, 'A');
|
||||||
|
flushSync();
|
||||||
|
assert.equal($.get(value), 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
destroy();
|
||||||
|
});
|
||||||
|
|
||||||
test('proxy version state does not trigger self-dependency guard', () => {
|
test('proxy version state does not trigger self-dependency guard', () => {
|
||||||
return () => {
|
return () => {
|
||||||
const s = proxy({ a: { b: 1 } });
|
const s = proxy({ a: { b: 1 } });
|
||||||
|
|||||||
Reference in new issue
Block a user