Skip to content

Commit

Permalink
failing test for first bug in #290
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Feb 24, 2017
1 parent b31ecc5 commit fcb1a3c
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/generator/component-events-each/Widget.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<button on:click='fire("foo")'>click me</button>
27 changes: 27 additions & 0 deletions test/generator/component-events-each/_config.js
Original file line number Diff line number Diff line change
@@ -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();
}
};
19 changes: 19 additions & 0 deletions test/generator/component-events-each/main.html
Original file line number Diff line number Diff line change
@@ -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>

0 comments on commit fcb1a3c

Please sign in to comment.