mirror of https://github.com/sveltejs/svelte
parent
945d8ce526
commit
a87d30e0e6
@ -0,0 +1 @@
|
|||||||
|
<input on:input='store.setName(this.value)'>
|
@ -0,0 +1,34 @@
|
|||||||
|
import Store from '../../../../store.js';
|
||||||
|
|
||||||
|
class MyStore extends Store {
|
||||||
|
setName(name) {
|
||||||
|
this.set({ name });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const store = new MyStore({
|
||||||
|
name: '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');
|
||||||
|
|
||||||
|
input.value = 'everybody';
|
||||||
|
input.dispatchEvent(event);
|
||||||
|
|
||||||
|
assert.equal(store.get('name'), 'everybody');
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
<h1>Hello everybody!</h1>
|
||||||
|
<input>
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,10 @@
|
|||||||
|
<h1>Hello {{$name}}!</h1>
|
||||||
|
<NameInput/>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import NameInput from './NameInput.html';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: { NameInput }
|
||||||
|
};
|
||||||
|
</script>
|
@ -0,0 +1 @@
|
|||||||
|
<button on:click='store.foo()'>foo</button>
|
@ -0,0 +1,8 @@
|
|||||||
|
[{
|
||||||
|
"message": "compile with `store: true` in order to call store methods",
|
||||||
|
"loc": {
|
||||||
|
"line": 1,
|
||||||
|
"column": 18
|
||||||
|
},
|
||||||
|
"pos": 18
|
||||||
|
}]
|
Loading…
Reference in new issue