mirror of https://github.com/sveltejs/svelte
28 lines
438 B
28 lines
438 B
export default {
|
|
data: {
|
|
thing: { a: 1 }
|
|
},
|
|
|
|
test ( assert, component ) {
|
|
const thing = component.get( 'thing' );
|
|
|
|
component.observe( 'thing', function ( thing ) {
|
|
thing.b = thing.a * 2;
|
|
this.set({ thing }); // triggers infinite loop, unless observer breaks it
|
|
});
|
|
|
|
assert.deepEqual( thing, {
|
|
a: 1,
|
|
b: 2
|
|
});
|
|
|
|
thing.a = 3;
|
|
component.set({ thing });
|
|
|
|
assert.deepEqual( thing, {
|
|
a: 3,
|
|
b: 6
|
|
});
|
|
}
|
|
};
|