From 1998739524c8c9992068ab701f182141a0c8ee58 Mon Sep 17 00:00:00 2001 From: Peter Maatman Date: Sun, 29 Sep 2019 19:28:00 +0200 Subject: [PATCH] tests: add tests for update expression --- .../reactive-update-expression/_config.js | 29 +++++++++++++++++++ .../reactive-update-expression/main.svelte | 12 ++++++++ 2 files changed, 41 insertions(+) create mode 100644 test/runtime/samples/reactive-update-expression/_config.js create mode 100644 test/runtime/samples/reactive-update-expression/main.svelte diff --git a/test/runtime/samples/reactive-update-expression/_config.js b/test/runtime/samples/reactive-update-expression/_config.js new file mode 100644 index 0000000000..c90da8255e --- /dev/null +++ b/test/runtime/samples/reactive-update-expression/_config.js @@ -0,0 +1,29 @@ +export default { + html: ` + +

count:1

+ `, + + async test({ assert, component, target, window }) { + const click = new window.MouseEvent('click'); + const button = target.querySelector('button'); + + assert.equal(component.x, 1); + + await button.dispatchEvent(click); + + assert.equal(component.x, 3); + assert.htmlEqual(target.innerHTML, ` + +

count:3

+ `); + + await button.dispatchEvent(click); + + assert.equal(component.x, 5); + assert.htmlEqual(target.innerHTML, ` + +

count:5

+ `); + } +}; diff --git a/test/runtime/samples/reactive-update-expression/main.svelte b/test/runtime/samples/reactive-update-expression/main.svelte new file mode 100644 index 0000000000..887d7a57e8 --- /dev/null +++ b/test/runtime/samples/reactive-update-expression/main.svelte @@ -0,0 +1,12 @@ + + + +

count:{x}