mirror of https://github.com/sveltejs/svelte
parent
8f3a6faaad
commit
834e342276
@ -1,27 +1,30 @@
|
|||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
items: [ 'a', 'b', 'c' ]
|
items: ['a', 'b', 'c']
|
||||||
},
|
},
|
||||||
|
|
||||||
html: `
|
html: `
|
||||||
<div><button>click me</button><button>click me</button><button>click me</button></div>
|
<div>
|
||||||
|
<button>click me</button>
|
||||||
|
<button>click me</button>
|
||||||
|
<button>click me</button>
|
||||||
|
</div>
|
||||||
`,
|
`,
|
||||||
|
|
||||||
test ( assert, component, target, window ) {
|
test(assert, component, target, window) {
|
||||||
const buttons = target.querySelectorAll( 'button' );
|
const buttons = target.querySelectorAll('button');
|
||||||
|
|
||||||
const clicks = [];
|
const clicks = [];
|
||||||
|
|
||||||
component.on( 'foo', item => {
|
component.$on('foo', event => {
|
||||||
clicks.push( item );
|
clicks.push(event.detail);
|
||||||
});
|
});
|
||||||
|
|
||||||
const event = new window.MouseEvent( 'click' );
|
const event = new window.MouseEvent('click');
|
||||||
|
|
||||||
buttons[0].dispatchEvent( event );
|
buttons[0].dispatchEvent(event);
|
||||||
buttons[2].dispatchEvent( event );
|
buttons[2].dispatchEvent(event);
|
||||||
|
|
||||||
assert.deepEqual( clicks, [ 'a', 'c' ]);
|
assert.deepEqual(clicks, ['a', 'c']);
|
||||||
component.destroy();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
export default {
|
|
||||||
html: '<div>empty</div>',
|
|
||||||
test ( assert, component, target ) {
|
|
||||||
assert.equal( component.created, true );
|
|
||||||
assert.equal( target.innerHTML, '<div>empty</div>' );
|
|
||||||
component.destroy();
|
|
||||||
}
|
|
||||||
};
|
|
@ -1,9 +0,0 @@
|
|||||||
<script>
|
|
||||||
import { onmount } from 'svelte';
|
|
||||||
|
|
||||||
onmount(() => {
|
|
||||||
created = true;
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div>empty</div>
|
|
@ -1,14 +1,14 @@
|
|||||||
export default {
|
export default {
|
||||||
html: '<p>50</p>',
|
html: '<p>50</p>',
|
||||||
|
|
||||||
test ( assert, component, target ) {
|
test(assert, component, target) {
|
||||||
component.range = [ 50, 100 ];
|
component.range = [50, 100];
|
||||||
assert.htmlEqual( target.innerHTML, '<p>75</p>' );
|
assert.htmlEqual(target.innerHTML, '<p>75</p>');
|
||||||
|
|
||||||
component.range = [ 50, 60 ];
|
component.range = [50, 60];
|
||||||
assert.htmlEqual( target.innerHTML, '<p>55</p>' );
|
assert.htmlEqual(target.innerHTML, '<p>55</p>');
|
||||||
|
|
||||||
component.x = 8;
|
component.x = 8;
|
||||||
assert.htmlEqual( target.innerHTML, '<p>58</p>' );
|
assert.htmlEqual(target.innerHTML, '<p>58</p>');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
export default {
|
|
||||||
html: '<p>2</p>',
|
|
||||||
|
|
||||||
'skip-ssr': /^v4/.test( process.version ), // we're not transpiling server-side tests in Node 4, because it's tricky
|
|
||||||
|
|
||||||
test ( assert, component, target ) {
|
|
||||||
component.a = 2;
|
|
||||||
assert.equal( target.innerHTML, '<p>4</p>' );
|
|
||||||
component.destroy();
|
|
||||||
}
|
|
||||||
};
|
|
@ -1,9 +0,0 @@
|
|||||||
<p>{foo}</p>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
computed: {
|
|
||||||
foo: ({ a = 1 }) => a * 2
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
@ -1,10 +1,10 @@
|
|||||||
export default {
|
export default {
|
||||||
html: '<p>2</p>',
|
html: '<p>2</p>',
|
||||||
|
|
||||||
test ( assert, component, target ) {
|
test(assert, component, target) {
|
||||||
component.y = 2;
|
component.y = 2;
|
||||||
assert.equal( component.x, 4 );
|
assert.equal(component.x, 4);
|
||||||
assert.equal( target.innerHTML, '<p>4</p>' );
|
assert.equal(target.innerHTML, '<p>4</p>');
|
||||||
component.destroy();
|
component.destroy();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
export default {
|
export default {
|
||||||
html: '<p>1 + 2 = 3</p>\n<p>3 * 3 = 9</p>',
|
html: '<p>1 + 2 = 3</p>\n<p>3 * 3 = 9</p>',
|
||||||
test ( assert, component, target ) {
|
|
||||||
|
test(assert, component, target) {
|
||||||
component.a = 3;
|
component.a = 3;
|
||||||
assert.equal( component.c, 5 );
|
assert.equal(component.c, 5);
|
||||||
assert.equal( component.cSquared, 25 );
|
assert.equal(component.cSquared, 25);
|
||||||
assert.equal( target.innerHTML, '<p>3 + 2 = 5</p>\n<p>5 * 5 = 25</p>' );
|
assert.equal(target.innerHTML, '<p>3 + 2 = 5</p>\n<p>5 * 5 = 25</p>');
|
||||||
component.destroy();
|
component.destroy();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
export default {
|
export default {
|
||||||
test ( assert, component, target ) {
|
test(assert, component, target) {
|
||||||
const items = component.items;
|
const items = component.items;
|
||||||
items.forEach( item => item.completed = false );
|
items.forEach(item => item.completed = false);
|
||||||
|
|
||||||
component.currentFilter = 'all';
|
component.currentFilter = 'all';
|
||||||
|
|
||||||
assert.htmlEqual( target.innerHTML, `
|
assert.htmlEqual(target.innerHTML, `
|
||||||
<ul><li>one</li><li>two</li><li>three</li></ul>`
|
<ul><li>one</li><li>two</li><li>three</li></ul>
|
||||||
);
|
`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in new issue