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 30, 2019
1 parent 5dda052 commit 88f2fcf
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/runtime/samples/reactive-compound-operator/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
export default {
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>
`);
}
};
8 changes: 8 additions & 0 deletions test/runtime/samples/reactive-compound-operator/main.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<script>
export let x = 0;
$: x *= 2;
</script>

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

0 comments on commit 88f2fcf

Please sign in to comment.