mirror of https://github.com/sveltejs/svelte
parent
097507796d
commit
c266051811
@ -1,20 +0,0 @@
|
|||||||
export default {
|
|
||||||
async test({ assert, component, target, window }) {
|
|
||||||
const button = target.querySelector('button');
|
|
||||||
const click = new window.MouseEvent('click');
|
|
||||||
|
|
||||||
await button.dispatchEvent(click);
|
|
||||||
assert.deepEqual(component.snapshots, [
|
|
||||||
'before 0',
|
|
||||||
'after 1'
|
|
||||||
]);
|
|
||||||
|
|
||||||
await button.dispatchEvent(click);
|
|
||||||
assert.deepEqual(component.snapshots, [
|
|
||||||
'before 0',
|
|
||||||
'after 1',
|
|
||||||
'before 1',
|
|
||||||
'after 2'
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
};
|
|
@ -1,19 +0,0 @@
|
|||||||
<script>
|
|
||||||
import { afterFlush } from 'svelte';
|
|
||||||
|
|
||||||
export let snapshots = [];
|
|
||||||
|
|
||||||
let count = 0;
|
|
||||||
let button;
|
|
||||||
|
|
||||||
function click() {
|
|
||||||
count += 1;
|
|
||||||
snapshots.push(`before ${button.textContent}`);
|
|
||||||
|
|
||||||
afterFlush(() => {
|
|
||||||
snapshots.push(`after ${button.textContent}`);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<button bind:this={button} on:click={click}>{count}</button>
|
|
@ -0,0 +1,30 @@
|
|||||||
|
export default {
|
||||||
|
async test({ assert, component, target, window }) {
|
||||||
|
const buttons = target.querySelectorAll('button');
|
||||||
|
const click = new window.MouseEvent('click');
|
||||||
|
|
||||||
|
await buttons[0].dispatchEvent(click);
|
||||||
|
assert.deepEqual(component.snapshots, [
|
||||||
|
'before 0',
|
||||||
|
'after 1'
|
||||||
|
]);
|
||||||
|
|
||||||
|
await buttons[0].dispatchEvent(click);
|
||||||
|
assert.deepEqual(component.snapshots, [
|
||||||
|
'before 0',
|
||||||
|
'after 1',
|
||||||
|
'before 1',
|
||||||
|
'after 2'
|
||||||
|
]);
|
||||||
|
|
||||||
|
await buttons[1].dispatchEvent(click);
|
||||||
|
assert.deepEqual(component.snapshots, [
|
||||||
|
'before 0',
|
||||||
|
'after 1',
|
||||||
|
'before 1',
|
||||||
|
'after 2',
|
||||||
|
'before 2',
|
||||||
|
'after 2'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,24 @@
|
|||||||
|
<script>
|
||||||
|
import { nextTick } from 'svelte';
|
||||||
|
|
||||||
|
export let snapshots = [];
|
||||||
|
|
||||||
|
let count = 0;
|
||||||
|
let buttons = [];
|
||||||
|
|
||||||
|
function increment() {
|
||||||
|
count += 1;
|
||||||
|
log();
|
||||||
|
}
|
||||||
|
|
||||||
|
function log() {
|
||||||
|
snapshots.push(`before ${buttons[0].textContent}`);
|
||||||
|
|
||||||
|
nextTick(() => {
|
||||||
|
snapshots.push(`after ${buttons[0].textContent}`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button bind:this={buttons[0]} on:click={increment}>{count}</button>
|
||||||
|
<button bind:this={buttons[1]} on:click={log}>{count}</button>
|
Loading…
Reference in new issue