mirror of https://github.com/sveltejs/svelte
parent
e835679f0f
commit
15f22ca745
@ -1,5 +1,7 @@
|
||||
<script>
|
||||
import One from './One.html';
|
||||
|
||||
export let one;
|
||||
</script>
|
||||
|
||||
<One ref:one/>
|
@ -1,17 +1,18 @@
|
||||
export default {
|
||||
html: '<button>+1</button>\n\n<p>0</p>',
|
||||
test ( assert, component, target, window ) {
|
||||
const button = target.querySelector( 'button' );
|
||||
const event = new window.MouseEvent( 'click' );
|
||||
|
||||
button.dispatchEvent( event );
|
||||
assert.equal( component.counter, 1 );
|
||||
assert.equal( target.innerHTML, '<button>+1</button>\n\n<p>1</p>' );
|
||||
async test(assert, component, target, window) {
|
||||
const button = target.querySelector('button');
|
||||
const event = new window.MouseEvent('click');
|
||||
|
||||
button.dispatchEvent( event );
|
||||
assert.equal( component.counter, 2 );
|
||||
assert.equal( target.innerHTML, '<button>+1</button>\n\n<p>2</p>' );
|
||||
await button.dispatchEvent(event);
|
||||
assert.equal(component.counter, 1);
|
||||
assert.equal(target.innerHTML, '<button>+1</button>\n\n<p>1</p>');
|
||||
|
||||
assert.equal( component.foo(), 42 );
|
||||
await button.dispatchEvent(event);
|
||||
assert.equal(component.counter, 2);
|
||||
assert.equal(target.innerHTML, '<button>+1</button>\n\n<p>2</p>');
|
||||
|
||||
assert.equal(component.foo(), 42);
|
||||
}
|
||||
};
|
||||
|
@ -1 +0,0 @@
|
||||
Bar
|
@ -1 +0,0 @@
|
||||
Foo
|
@ -1,16 +0,0 @@
|
||||
export default {
|
||||
compileOptions: {
|
||||
dev: true
|
||||
},
|
||||
|
||||
props: {
|
||||
x: true
|
||||
},
|
||||
|
||||
html: '',
|
||||
|
||||
warnings: [
|
||||
`<Main$> expected to find 'Foo' in \`data\`, but found it in \`components\` instead`,
|
||||
`<Main$> expected to find 'Bar' in \`data\`, but found it in \`components\` instead`
|
||||
]
|
||||
};
|
@ -1,10 +0,0 @@
|
||||
<script>
|
||||
import Foo from './Foo.html';
|
||||
import Bar from './Bar.html';
|
||||
|
||||
export let x;
|
||||
export let Foo;
|
||||
export let Bar;
|
||||
</script>
|
||||
|
||||
<svelte:component this="{x ? Foo : Bar}"/>
|
Loading…
Reference in new issue