failing test for second part of #1100

pull/1170/head
Rich Harris 7 years ago
parent 173792fd90
commit cccc3e4c41

@ -0,0 +1,42 @@
import { Store } from '../../../../store.js';
const store = new Store({
name: {
value: 'world'
}
});
export default {
store,
html: `
<h1>Hello world!</h1>
<input>
`,
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, `
<h1>Hello everybody!</h1>
<input>
`);
assert.deepEqual(changeRecord, [
{
state: { name: { value: 'everybody' } },
changes: { name: true }
}
]);
}
};

@ -0,0 +1,10 @@
<h1>Hello {{$name.value}}!</h1>
<TextInput bind:value=$name.value/>
<script>
import TextInput from './TextInput.html';
export default {
components: { TextInput }
};
</script>

@ -16,6 +16,11 @@ export default {
const input = target.querySelector('input'); const input = target.querySelector('input');
const event = new window.Event('input'); const event = new window.Event('input');
const changeRecord = [];
store.onchange((state, changes) => {
changeRecord.push({ state, changes });
});
input.value = 'everybody'; input.value = 'everybody';
input.dispatchEvent(event); input.dispatchEvent(event);
@ -24,5 +29,12 @@ export default {
<h1>Hello everybody!</h1> <h1>Hello everybody!</h1>
<input> <input>
`); `);
assert.deepEqual(changeRecord, [
{
state: { name: 'everybody' },
changes: { name: true }
}
]);
} }
}; };
Loading…
Cancel
Save