You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/test/runtime/samples/observe-prevents-loop/_config.js

30 lines
487 B

export default {
props: {
thing: { a: 1 }
},
test(assert, component) {
const thing = component.thing;
component.on('state', ({ changed, current }) => {
if (changed.thing) {
const { thing } = current;
thing.b = thing.a * 2;
component.thing = thing; // triggers infinite loop, unless event handler breaks it
}
});
assert.deepEqual(thing, {
a: 1
});
thing.a = 3;
component.thing = thing;
assert.deepEqual(thing, {
a: 3,
b: 6
});
}
};