add some onstate/onupdate tests

pull/1344/head
Rich Harris 7 years ago
parent 85c8054fa0
commit 33afb7e49a

@ -0,0 +1,21 @@
export default {
solo: true,
'skip-ssr': true,
data: {
value: 'hello!'
},
html: `
<p>hello!</p>
<p>hello!</p>
`,
test(assert, component, target) {
component.set({ value: 'goodbye!' });
assert.htmlEqual(target.innerHTML, `
<p>goodbye!</p>
<p>goodbye!</p>
`);
}
};

@ -0,0 +1,12 @@
<p ref:a>{{value}}</p>
<p ref:b></p>
<script>
export default {
onupdate({ changed, current, previous }) {
if (changed.value) {
this.refs.b.textContent = this.refs.a.textContent;
}
}
};
</script>

@ -0,0 +1,5 @@
<script>
export default {
onstate: () => console.log('updating')
};
</script>

@ -0,0 +1,12 @@
[{
"message": "'onstate' should be a function expression, not an arrow function expression",
"pos": 29,
"loc": {
"line": 3,
"column": 2
},
"end": {
"line": 5,
"column": 3
}
}]

@ -0,0 +1,7 @@
<script>
export default {
onstate: () => {
this.set({ a: 1 });
}
};
</script>

@ -0,0 +1,5 @@
<script>
export default {
onupdate: () => console.log('updating')
};
</script>

@ -0,0 +1,12 @@
[{
"message": "'onupdate' should be a function expression, not an arrow function expression",
"pos": 29,
"loc": {
"line": 3,
"column": 2
},
"end": {
"line": 5,
"column": 3
}
}]

@ -0,0 +1,7 @@
<script>
export default {
onupdate: () => {
this.set({ a: 1 });
}
};
</script>
Loading…
Cancel
Save