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 0000000000..f24d608cd5 --- /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 0000000000..66ae5ac4ae --- /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 0000000000..f77016b549 --- /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 aefc4ec652..1d2beab7a7 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