mirror of https://github.com/sveltejs/svelte
parent
487fedce6c
commit
501e334ce7
@ -0,0 +1,43 @@
|
|||||||
|
export default {
|
||||||
|
html: `
|
||||||
|
<button>click</button>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td><span>1-a</span></td>
|
||||||
|
<td><span>1-b</span></td>
|
||||||
|
<td><span>1-c</span></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><span>2-a</span></td>
|
||||||
|
<td><span>2-b</span></td>
|
||||||
|
<td><span>2-c</span></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><span>3-a</span></td>
|
||||||
|
<td><span>3-b</span></td>
|
||||||
|
<td><span>3-c</span></td>
|
||||||
|
</tr>
|
||||||
|
</table>`,
|
||||||
|
async test({ assert, target, window }) {
|
||||||
|
const button = target.querySelector('button');
|
||||||
|
const event = new window.MouseEvent('click');
|
||||||
|
await button.dispatchEvent(event);
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
<button>click</button>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td><span>1-a</span></td>
|
||||||
|
<td><span>1-c</span></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><span>3-a</span></td>
|
||||||
|
<td><span>3-c</span></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><span>2-a</span></td>
|
||||||
|
<td><span>2-c</span></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
};
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
<script>
|
||||||
|
import Sub from './sub.svelte';
|
||||||
|
|
||||||
|
export let columns = ['a', 'b', 'c'];
|
||||||
|
export let rows = ['1', '2', '3'];
|
||||||
|
|
||||||
|
function onClick() {
|
||||||
|
columns = ['a', 'c'];
|
||||||
|
rows = ['1', '3', '2'];
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button on:click={onClick}>click</button>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
{#each rows as row (row)}
|
||||||
|
<tr>
|
||||||
|
{#each columns as column}
|
||||||
|
<td>
|
||||||
|
<Sub {row} {column} />
|
||||||
|
</td>
|
||||||
|
{/each}
|
||||||
|
</tr>
|
||||||
|
{/each}
|
||||||
|
</table>
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
<script>
|
||||||
|
export let row;
|
||||||
|
export let column;
|
||||||
|
</script>
|
||||||
|
<span>{row}-{column}</span>
|
||||||
@ -0,0 +1,43 @@
|
|||||||
|
export default {
|
||||||
|
html: `
|
||||||
|
<button>click</button>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td><span>1-a</span></td>
|
||||||
|
<td><span>1-b</span></td>
|
||||||
|
<td><span>1-c</span></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><span>2-a</span></td>
|
||||||
|
<td><span>2-b</span></td>
|
||||||
|
<td><span>2-c</span></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><span>3-a</span></td>
|
||||||
|
<td><span>3-b</span></td>
|
||||||
|
<td><span>3-c</span></td>
|
||||||
|
</tr>
|
||||||
|
</table>`,
|
||||||
|
async test({ assert, target, window }) {
|
||||||
|
const button = target.querySelector('button');
|
||||||
|
const event = new window.MouseEvent('click');
|
||||||
|
await button.dispatchEvent(event);
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
<button>click</button>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td><span>1-a</span></td>
|
||||||
|
<td><span>1-c</span></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><span>3-a</span></td>
|
||||||
|
<td><span>3-c</span></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><span>2-a</span></td>
|
||||||
|
<td><span>2-c</span></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
};
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
<script>
|
||||||
|
import Sub from './sub.svelte';
|
||||||
|
|
||||||
|
export let columns = ['a', 'b', 'c'];
|
||||||
|
export let rows = ['1', '2', '3'];
|
||||||
|
|
||||||
|
function onClick() {
|
||||||
|
columns = ['a', 'c'];
|
||||||
|
rows = ['1', '3', '2'];
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button on:click={onClick}>click</button>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
{#each rows as row}
|
||||||
|
<tr>
|
||||||
|
{#each columns as column}
|
||||||
|
<td>
|
||||||
|
<Sub {row} {column} />
|
||||||
|
</td>
|
||||||
|
{/each}
|
||||||
|
</tr>
|
||||||
|
{/each}
|
||||||
|
</table>
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
<script>
|
||||||
|
export let row;
|
||||||
|
export let column;
|
||||||
|
</script>
|
||||||
|
<span>{row}-{column}</span>
|
||||||
Loading…
Reference in new issue