update tests

pull/1864/head
Rich Harris 7 years ago
parent 4c2fdcf657
commit f13c2272df

@ -1 +1,11 @@
<script>
import { onDestroy, createEventDispatcher } from 'svelte';
const dispatch = createEventDispatcher();
onDestroy(() => {
dispatch('destroy');
});
</script>
<p>i am a widget</p> <p>i am a widget</p>

@ -5,19 +5,19 @@ export default {
html: '<div><p>i am a widget</p></div>', html: '<div><p>i am a widget</p></div>',
test ( assert, component ) { test(assert, component) {
let count = 0; let count = 0;
component.$on( 'widgetTornDown', function () { component.$on('widgetTornDown', function() {
assert.equal( this, component ); assert.equal(this, component);
count += 1; count += 1;
}); });
component.visible = false; component.visible = false;
assert.equal( count, 1 ); assert.equal(count, 1);
component.visible = true; component.visible = true;
component.visible = false; component.visible = false;
assert.equal( count, 2 ); assert.equal(count, 2);
} }
}; };

@ -1,5 +1,5 @@
export default { export default {
test(assert, component) { test(assert, component) {
component.l1.destroy(); component.l1.$destroy();
} }
}; };

@ -1,5 +1,7 @@
<script> <script>
import Level1 from './Level1.html'; import Level1 from './Level1.html';
export let l1;
</script> </script>
<Level1 ref:l1 /> <Level1 ref:l1 />

@ -1,4 +1,6 @@
<div class="level2" ref:wat>
<div class="level2">
<h4>level 2</h4> <h4>level 2</h4>
{#if condition} {#if condition}
<span>TRUE! <slot></slot></span> <span>TRUE! <slot></slot></span>

@ -1,4 +1,4 @@
<div class="level3" ref:thingy> <div class="level3">
<h4>level 3</h4> <h4>level 3</h4>
<slot></slot> <slot></slot>
</div> </div>

@ -1,7 +1,8 @@
export default { export default {
html: '<div><p>i am a widget</p></div>', html: '<div><p>i am a widget</p></div>',
test ( assert, component ) {
const widget = component.widget; test(assert, component) {
assert.ok( widget.isWidget ); const { widget } = component;
assert.ok(widget.isWidget);
} }
}; };

@ -1,5 +1,6 @@
<script> <script>
import Widget from './Widget.html'; import Widget from './Widget.html';
export let widget;
</script> </script>
<div> <div>

@ -12,13 +12,13 @@ export default {
</div> </div>
`, `,
test ( assert, component, target, window ) { test(assert, component, target, window) {
const button = target.querySelector( 'button' ); const button = target.querySelector('button');
const click = new window.MouseEvent( 'click' ); const click = new window.MouseEvent('click');
button.dispatchEvent( click ); button.dispatchEvent(click);
assert.htmlEqual( target.innerHTML, ` assert.htmlEqual(target.innerHTML, `
<button>show modal</button> <button>show modal</button>
`); `);
} }

Loading…
Cancel
Save