mirror of https://github.com/sveltejs/svelte
parent
a534c66d5b
commit
9dfc89ecd7
@ -1,6 +1,7 @@
|
||||
import { Node } from '../interfaces';
|
||||
|
||||
export default function getObject(node: Node) {
|
||||
while (node.type === 'ParenthesizedExpression') node = node.expression;
|
||||
while (node.type === 'MemberExpression') node = node.object;
|
||||
return node;
|
||||
}
|
||||
|
@ -0,0 +1,17 @@
|
||||
export default {
|
||||
html: `
|
||||
<button>foo</button>
|
||||
<p>x: 0</p>
|
||||
`,
|
||||
|
||||
async test({ assert, component, target, window }) {
|
||||
const buttons = target.querySelectorAll('button');
|
||||
const click = new window.MouseEvent('click');
|
||||
|
||||
await buttons[0].dispatchEvent(click);
|
||||
assert.htmlEqual(target.innerHTML, `
|
||||
<button>foo</button>
|
||||
<p>x: 1</p>
|
||||
`);
|
||||
}
|
||||
};
|
@ -0,0 +1,11 @@
|
||||
<script>
|
||||
let x = 0;
|
||||
|
||||
function foo() {
|
||||
x++;
|
||||
}
|
||||
</script>
|
||||
|
||||
<button on:click={foo}>foo</button>
|
||||
|
||||
<p>x: {x}</p>
|
@ -0,0 +1,17 @@
|
||||
export default {
|
||||
html: `
|
||||
<button>foo</button>
|
||||
<p>x: 0</p>
|
||||
`,
|
||||
|
||||
async test({ assert, component, target, window }) {
|
||||
const buttons = target.querySelectorAll('button');
|
||||
const click = new window.MouseEvent('click');
|
||||
|
||||
await buttons[0].dispatchEvent(click);
|
||||
assert.htmlEqual(target.innerHTML, `
|
||||
<button>foo</button>
|
||||
<p>x: 1</p>
|
||||
`);
|
||||
}
|
||||
};
|
@ -0,0 +1,7 @@
|
||||
<script>
|
||||
let x = 0;
|
||||
</script>
|
||||
|
||||
<button on:click="{() => x++}">foo</button>
|
||||
|
||||
<p>x: {x}</p>
|
Loading…
Reference in new issue