pull/378/head
Rich Harris 8 years ago
parent 9b6e3e75a3
commit a801e1843b

@ -96,6 +96,11 @@ describe( 'generate', () => {
// Put the constructor on window for testing // Put the constructor on window for testing
window.SvelteComponent = SvelteComponent; window.SvelteComponent = SvelteComponent;
const warnings = [];
window.console.warn = warning => {
warnings.push( warning );
};
const target = window.document.querySelector( 'main' ); const target = window.document.querySelector( 'main' );
const component = new SvelteComponent({ const component = new SvelteComponent({
@ -108,6 +113,13 @@ describe( 'generate', () => {
throw new Error( 'Expected a runtime error' ); throw new Error( 'Expected a runtime error' );
} }
if ( config.warnings ) {
assert.deepEqual( warnings, config.warnings );
} else if ( warnings.length ) {
unintendedError = true;
throw new Error( 'Received unexpected warnings' );
}
if ( config.html ) { if ( config.html ) {
assert.htmlEqual( target.innerHTML, config.html ); assert.htmlEqual( target.innerHTML, config.html );
} }

@ -0,0 +1,7 @@
export default {
dev: true,
error ( assert, err ) {
assert.equal( err.message, `The fisrt argument to component.observe(...) must be the name of a top-level property, i.e. 'nested' rather than 'nested.data'` );
}
};

@ -0,0 +1,9 @@
<script>
export default {
oncreate () {
this.observe( 'nested.data', data => {
console.log( 'nope' );
});
}
};
</script>

@ -0,0 +1,7 @@
export default {
dev: true,
warnings: [
`Use component.on('destroy', ...) instead of component.on('teardown', ...) which has been deprecated`
]
};

@ -0,0 +1,9 @@
<script>
export default {
oncreate () {
this.on( 'teardown', () => {
this.destroyed = true;
});
}
};
</script>
Loading…
Cancel
Save