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.
svelte/test/generator/samples/component-events-each/_config.js

28 lines
547 B

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.destroy();
}
};