mirror of https://github.com/sveltejs/svelte
commit
79b5ce090e
@ -0,0 +1,36 @@
|
||||
export default {
|
||||
data: {
|
||||
foo: [ 1 ],
|
||||
bar: [ 2 ],
|
||||
clicked: 'neither'
|
||||
},
|
||||
|
||||
html: `
|
||||
<button>foo</button>
|
||||
<button>bar</button>
|
||||
<p>clicked: neither</p>
|
||||
`,
|
||||
|
||||
test ( assert, component, target, window ) {
|
||||
const buttons = target.querySelectorAll( 'button' );
|
||||
const event = new window.MouseEvent( 'click' );
|
||||
|
||||
buttons[0].dispatchEvent( event );
|
||||
assert.equal( component.get( 'clicked' ), 'foo' );
|
||||
assert.htmlEqual( target.innerHTML, `
|
||||
<button>foo</button>
|
||||
<button>bar</button>
|
||||
<p>clicked: foo</p>
|
||||
` );
|
||||
|
||||
buttons[1].dispatchEvent( event );
|
||||
assert.equal( component.get( 'clicked' ), 'bar' );
|
||||
assert.htmlEqual( target.innerHTML, `
|
||||
<button>foo</button>
|
||||
<button>bar</button>
|
||||
<p>clicked: bar</p>
|
||||
` );
|
||||
|
||||
component.destroy();
|
||||
}
|
||||
};
|
@ -0,0 +1,9 @@
|
||||
{{#each foo as f}}
|
||||
<button on:click='set({ clicked: "foo" })'>foo</button>
|
||||
{{/each}}
|
||||
|
||||
{{#each bar as b}}
|
||||
<button on:click='set({ clicked: "bar" })'>bar</button>
|
||||
{{/each}}
|
||||
|
||||
<p>clicked: {{clicked}}</p>
|
@ -0,0 +1,12 @@
|
||||
export default {
|
||||
skip: true, // JSDOM
|
||||
|
||||
test ( assert, component, target, window ) {
|
||||
assert.equal( window.scrollY, 0 );
|
||||
|
||||
component.set({ scrollY: 100 });
|
||||
assert.equal( window.scrollY, 100 );
|
||||
|
||||
component.destroy();
|
||||
}
|
||||
};
|
@ -0,0 +1,3 @@
|
||||
<:Window bind:scrollY/>
|
||||
|
||||
<div style='width: 100%; height: 9999px;'></div>
|
Loading…
Reference in new issue