forked from sveltejs/svelte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add test that exposes sveltejs#3634
- Loading branch information
1 parent
5dda052
commit 90d4b91
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
test/runtime/samples/reactive-compound-operator/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
`); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |