Skip to content

Commit

Permalink
tests: add test that exposes sveltejs#3634
Browse files Browse the repository at this point in the history
  • Loading branch information
blackwolf12333 committed Sep 29, 2019
1 parent 5dda052 commit 90d4b91
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/runtime/samples/reactive-compound-operator/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
export default {
skip_if_ssr: true, // TODO delete this line, once binding works

html: `
<button>+1</button>
<p>count: 0</p>
`,

async test({ assert, component, target, window }) {
const click = new window.MouseEvent('click');
const button = target.querySelector('button');

await button.dispatchEvent(click);

assert.equal(component.x, 2);
assert.htmlEqual(target.innerHTML, `
<button>+1</button>
<p>count: 2</p>
`);

await button.dispatchEvent(click);

assert.equal(component.x, 6);
assert.htmlEqual(target.innerHTML, `
<button>+1</button>
<p>count: 6</p>
`);
}
};
9 changes: 9 additions & 0 deletions test/runtime/samples/reactive-compound-operator/main.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<script>
export let x = 0;
$: x *= 2;
</script>

<button on:click='{() => x += 1}'>+1</button>
<p>count: {x}</p>

0 comments on commit 90d4b91

Please sign in to comment.