mirror of https://github.com/sveltejs/svelte
parent
3789c714d0
commit
73d269c286
@ -1,7 +0,0 @@
|
|||||||
export default {
|
|
||||||
test ( assert, component ) {
|
|
||||||
assert.equal( component.a, 1 );
|
|
||||||
assert.equal( component.c, 3 );
|
|
||||||
assert.deepEqual( component, { a: 1, b: 2, c: 3 });
|
|
||||||
}
|
|
||||||
};
|
|
@ -1,8 +0,0 @@
|
|||||||
<script>
|
|
||||||
export let a = 1;
|
|
||||||
export let b = 2;
|
|
||||||
|
|
||||||
export function c() {
|
|
||||||
return a + b;
|
|
||||||
}
|
|
||||||
</script>
|
|
@ -1,7 +1,7 @@
|
|||||||
export default {
|
export default {
|
||||||
html: '',
|
html: '',
|
||||||
|
|
||||||
test ( assert, component, target ) {
|
test(assert, component, target) {
|
||||||
assert.htmlEqual( target.innerHTML, 'NaN' );
|
assert.htmlEqual(target.innerHTML, 'NaN');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,49 +0,0 @@
|
|||||||
export default {
|
|
||||||
'skip-ssr': true,
|
|
||||||
|
|
||||||
props: {
|
|
||||||
foo: 'woo!'
|
|
||||||
},
|
|
||||||
|
|
||||||
html: `
|
|
||||||
<p>woo!</p>
|
|
||||||
<p>undefined</p>
|
|
||||||
`,
|
|
||||||
|
|
||||||
test(assert, component, target) {
|
|
||||||
const history = [];
|
|
||||||
|
|
||||||
component.$on('state', ({ changed, current, previous }) => {
|
|
||||||
history.push({ changed, current, previous });
|
|
||||||
component.bar = current.foo.toUpperCase();
|
|
||||||
});
|
|
||||||
|
|
||||||
component.foo = 'yeah!';
|
|
||||||
assert.htmlEqual(target.innerHTML, `
|
|
||||||
<p>yeah!</p>
|
|
||||||
<p>YEAH!</p>
|
|
||||||
`);
|
|
||||||
|
|
||||||
component.unused = 'x';
|
|
||||||
|
|
||||||
assert.deepEqual(history, [
|
|
||||||
{
|
|
||||||
changed: { foo: true },
|
|
||||||
current: { foo: 'yeah!' },
|
|
||||||
previous: { foo: 'woo!' }
|
|
||||||
},
|
|
||||||
// this is NOT received, because Svelte will not allow
|
|
||||||
// an event handler to trigger itself recursively
|
|
||||||
// {
|
|
||||||
// changed: { bar: true },
|
|
||||||
// current: { foo: 'yeah!', bar: 'YEAH!' },
|
|
||||||
// previous: { foo: 'yeah!' }
|
|
||||||
// },
|
|
||||||
{
|
|
||||||
changed: { unused: true },
|
|
||||||
current: { foo: 'yeah!', bar: 'YEAH!', unused: 'x' },
|
|
||||||
previous: { foo: 'yeah!', bar: 'YEAH!' }
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
};
|
|
@ -1,2 +0,0 @@
|
|||||||
<p>{foo}</p>
|
|
||||||
<p>{bar}</p>
|
|
@ -1,20 +0,0 @@
|
|||||||
export default {
|
|
||||||
'skip-ssr': true,
|
|
||||||
|
|
||||||
props: {
|
|
||||||
value: 'hello!'
|
|
||||||
},
|
|
||||||
|
|
||||||
html: `
|
|
||||||
<p>hello!</p>
|
|
||||||
<p>hello!</p>
|
|
||||||
`,
|
|
||||||
|
|
||||||
test(assert, component, target) {
|
|
||||||
component.value = 'goodbye!';
|
|
||||||
assert.htmlEqual(target.innerHTML, `
|
|
||||||
<p>goodbye!</p>
|
|
||||||
<p>goodbye!</p>
|
|
||||||
`);
|
|
||||||
}
|
|
||||||
};
|
|
@ -1,15 +0,0 @@
|
|||||||
<script>
|
|
||||||
import { afterRender } from 'svelte';
|
|
||||||
|
|
||||||
export let a;
|
|
||||||
export let b;
|
|
||||||
|
|
||||||
export let value;
|
|
||||||
|
|
||||||
afterRender(() => {
|
|
||||||
b.textContent = a.textContent;
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<p ref:a>{value}</p>
|
|
||||||
<p ref:b></p>
|
|
Loading…
Reference in new issue