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 88f2fcf
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
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,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> | ||
`); | ||
} | ||
}; |
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,8 @@ | ||
<script> | ||
export let x = 0; | ||
$: x *= 2; | ||
</script> | ||
|
||
<button on:click='{() => x += 1}'>+1</button> | ||
<p>count:{x}</p> |