From a42cae3a0bfcf33800aecc2c86273563ea283ad2 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Sun, 9 Feb 2020 20:22:33 -0500 Subject: [PATCH] add test --- .../binding-indirect-spread/_config.js | 44 +++++++++++++++++++ .../binding-indirect-spread/main.svelte | 12 +++++ 2 files changed, 56 insertions(+) create mode 100644 test/runtime/samples/binding-indirect-spread/_config.js create mode 100644 test/runtime/samples/binding-indirect-spread/main.svelte diff --git a/test/runtime/samples/binding-indirect-spread/_config.js b/test/runtime/samples/binding-indirect-spread/_config.js new file mode 100644 index 0000000000..1f24fcdbcb --- /dev/null +++ b/test/runtime/samples/binding-indirect-spread/_config.js @@ -0,0 +1,44 @@ +export default { + skip_if_ssr: true, + async test({ assert, component, target, window }) { + const event = new window.MouseEvent('click'); + + const [radio1, radio2, radio3] = target.querySelectorAll('input[type=radio]'); + + assert.ok(!radio1.checked); + assert.ok(radio2.checked); + assert.ok(!radio3.checked); + + component.radio = 'radio1'; + + assert.ok(radio1.checked); + assert.ok(!radio2.checked); + assert.ok(!radio3.checked); + + await radio3.dispatchEvent(event); + + assert.equal(component.radio, 'radio3'); + assert.ok(!radio1.checked); + assert.ok(!radio2.checked); + assert.ok(radio3.checked); + + const [check1, check2, check3] = target.querySelectorAll('input[type=checkbox]'); + + assert.ok(!check1.checked); + assert.ok(check2.checked); + assert.ok(!check3.checked); + + component.check = ['check1', 'check2']; + + assert.ok(check1.checked); + assert.ok(check2.checked); + assert.ok(!check3.checked); + + await check3.dispatchEvent(event); + + assert.deepEqual(component.check, ['check1', 'check2', 'check3']); + assert.ok(check1.checked); + assert.ok(check2.checked); + assert.ok(check3.checked); + } +}; diff --git a/test/runtime/samples/binding-indirect-spread/main.svelte b/test/runtime/samples/binding-indirect-spread/main.svelte new file mode 100644 index 0000000000..43129b08b7 --- /dev/null +++ b/test/runtime/samples/binding-indirect-spread/main.svelte @@ -0,0 +1,12 @@ + + + + + + + + +