mirror of https://github.com/sveltejs/svelte
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.
28 lines
438 B
28 lines
438 B
8 years ago
|
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
|
||
|
});
|
||
|
}
|
||
|
};
|