mirror of https://github.com/sveltejs/svelte
failing test for first bug in #290
parent
b31ecc5649
commit
fcb1a3c296
@ -0,0 +1 @@
|
||||
<button on:click='fire("foo")'>click me</button>
|
@ -0,0 +1,27 @@
|
||||
export default {
|
||||
data: {
|
||||
items: [ 'a', 'b', 'c' ]
|
||||
},
|
||||
|
||||
html: `
|
||||
<div><button>click me</button><button>click me</button><button>click me</button></div>
|
||||
`,
|
||||
|
||||
test ( assert, component, target, window ) {
|
||||
const buttons = target.querySelectorAll( 'button' );
|
||||
|
||||
const clicks = [];
|
||||
|
||||
component.on( 'foo', item => {
|
||||
clicks.push( item );
|
||||
});
|
||||
|
||||
const event = new window.MouseEvent( 'click' );
|
||||
|
||||
buttons[0].dispatchEvent( event );
|
||||
buttons[2].dispatchEvent( event );
|
||||
|
||||
assert.deepEqual( clicks, [ 'a', 'c' ]);
|
||||
component.teardown();
|
||||
}
|
||||
};
|
@ -0,0 +1,19 @@
|
||||
<div>
|
||||
{{#each items as item}}
|
||||
<Widget on:foo='foo(item)'/>
|
||||
{{/each}}
|
||||
</div>
|
||||
|
||||
<script>
|
||||
import Widget from './Widget.html';
|
||||
|
||||
export default {
|
||||
components: { Widget },
|
||||
|
||||
methods: {
|
||||
foo ( item ) {
|
||||
this.fire( 'foo', item );
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
Loading…
Reference in new issue