From cccc3e4c41ef912566be20c35afe2fccaf00770c Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sat, 10 Feb 2018 13:01:27 -0500 Subject: [PATCH] failing test for second part of #1100 --- .../TextInput.html | 1 + .../store-component-binding-deep/_config.js | 42 +++++++++++++++++++ .../store-component-binding-deep/main.html | 10 +++++ .../store-component-binding/_config.js | 12 ++++++ 4 files changed, 65 insertions(+) create mode 100644 test/runtime/samples/store-component-binding-deep/TextInput.html create mode 100644 test/runtime/samples/store-component-binding-deep/_config.js create mode 100644 test/runtime/samples/store-component-binding-deep/main.html diff --git a/test/runtime/samples/store-component-binding-deep/TextInput.html b/test/runtime/samples/store-component-binding-deep/TextInput.html new file mode 100644 index 000000000000..f24d608cd586 --- /dev/null +++ b/test/runtime/samples/store-component-binding-deep/TextInput.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/runtime/samples/store-component-binding-deep/_config.js b/test/runtime/samples/store-component-binding-deep/_config.js new file mode 100644 index 000000000000..66ae5ac4ae22 --- /dev/null +++ b/test/runtime/samples/store-component-binding-deep/_config.js @@ -0,0 +1,42 @@ +import { Store } from '../../../../store.js'; + +const store = new Store({ + name: { + value: 'world' + } +}); + +export default { + store, + + html: ` +

Hello world!

+ + `, + + test(assert, component, target, window) { + const input = target.querySelector('input'); + const event = new window.Event('input'); + + const changeRecord = []; + store.onchange((state, changes) => { + changeRecord.push({ state, changes }); + }); + + input.value = 'everybody'; + input.dispatchEvent(event); + + assert.equal(store.get('name').value, 'everybody'); + assert.htmlEqual(target.innerHTML, ` +

Hello everybody!

+ + `); + + assert.deepEqual(changeRecord, [ + { + state: { name: { value: 'everybody' } }, + changes: { name: true } + } + ]); + } +}; \ No newline at end of file diff --git a/test/runtime/samples/store-component-binding-deep/main.html b/test/runtime/samples/store-component-binding-deep/main.html new file mode 100644 index 000000000000..f77016b5494c --- /dev/null +++ b/test/runtime/samples/store-component-binding-deep/main.html @@ -0,0 +1,10 @@ +

Hello {{$name.value}}!

+ + + \ No newline at end of file diff --git a/test/runtime/samples/store-component-binding/_config.js b/test/runtime/samples/store-component-binding/_config.js index aefc4ec652ac..1d2beab7a778 100644 --- a/test/runtime/samples/store-component-binding/_config.js +++ b/test/runtime/samples/store-component-binding/_config.js @@ -16,6 +16,11 @@ export default { const input = target.querySelector('input'); const event = new window.Event('input'); + const changeRecord = []; + store.onchange((state, changes) => { + changeRecord.push({ state, changes }); + }); + input.value = 'everybody'; input.dispatchEvent(event); @@ -24,5 +29,12 @@ export default {

Hello everybody!

`); + + assert.deepEqual(changeRecord, [ + { + state: { name: 'everybody' }, + changes: { name: true } + } + ]); } }; \ No newline at end of file