mirror of https://github.com/sveltejs/svelte
commit
2f75fe906a
@ -0,0 +1,44 @@
|
||||
export default {
|
||||
skip_if_ssr: true,
|
||||
async test({ assert, component, target, window }) {
|
||||
const event = new window.MouseEvent('click');
|
||||
|
||||
const [radio1, radio2, radio3] = target.querySelectorAll('input[type=radio]');
|
||||
|
||||
assert.ok(!radio1.checked);
|
||||
assert.ok(radio2.checked);
|
||||
assert.ok(!radio3.checked);
|
||||
|
||||
component.radio = 'radio1';
|
||||
|
||||
assert.ok(radio1.checked);
|
||||
assert.ok(!radio2.checked);
|
||||
assert.ok(!radio3.checked);
|
||||
|
||||
await radio3.dispatchEvent(event);
|
||||
|
||||
assert.equal(component.radio, 'radio3');
|
||||
assert.ok(!radio1.checked);
|
||||
assert.ok(!radio2.checked);
|
||||
assert.ok(radio3.checked);
|
||||
|
||||
const [check1, check2, check3] = target.querySelectorAll('input[type=checkbox]');
|
||||
|
||||
assert.ok(!check1.checked);
|
||||
assert.ok(check2.checked);
|
||||
assert.ok(!check3.checked);
|
||||
|
||||
component.check = ['check1', 'check2'];
|
||||
|
||||
assert.ok(check1.checked);
|
||||
assert.ok(check2.checked);
|
||||
assert.ok(!check3.checked);
|
||||
|
||||
await check3.dispatchEvent(event);
|
||||
|
||||
assert.deepEqual(component.check, ['check1', 'check2', 'check3']);
|
||||
assert.ok(check1.checked);
|
||||
assert.ok(check2.checked);
|
||||
assert.ok(check3.checked);
|
||||
}
|
||||
};
|
@ -0,0 +1,12 @@
|
||||
<script>
|
||||
export let radio = 'radio2';
|
||||
export let check = ['check2'];
|
||||
</script>
|
||||
|
||||
<input type='radio' bind:group={radio} value='radio1' {...{}}>
|
||||
<input type='radio' bind:group={radio} value='radio2' {...{}}>
|
||||
<input type='radio' bind:group={radio} value='radio3' {...{}}>
|
||||
|
||||
<input type='checkbox' bind:group={check} value='check1' {...{}}>
|
||||
<input type='checkbox' bind:group={check} value='check2' {...{}}>
|
||||
<input type='checkbox' bind:group={check} value='check3' {...{}}>
|
@ -0,0 +1,23 @@
|
||||
export default {
|
||||
html: `
|
||||
<button>Click Me</button>
|
||||
0
|
||||
<ul></ul>
|
||||
`,
|
||||
|
||||
async test({ assert, component, target, window }) {
|
||||
const button = target.querySelector("button");
|
||||
|
||||
const event = new window.MouseEvent("click");
|
||||
await button.dispatchEvent(event);
|
||||
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`
|
||||
<button>Click Me</button>
|
||||
1
|
||||
<ul></ul>
|
||||
`
|
||||
);
|
||||
}
|
||||
};
|
@ -0,0 +1,20 @@
|
||||
<script>
|
||||
let num = 0;
|
||||
let cards = [];
|
||||
|
||||
function click() {
|
||||
// updating cards via push should have no effect to the ul,
|
||||
// since its being mutated instead of reassigned
|
||||
cards.push(num++);
|
||||
}
|
||||
</script>
|
||||
<button on:click={click}>
|
||||
Click Me
|
||||
</button>
|
||||
|
||||
{num}
|
||||
<ul>
|
||||
{#each cards as c, i (i)}
|
||||
<li>{c}</li>
|
||||
{/each}
|
||||
</ul>
|
@ -0,0 +1,18 @@
|
||||
<script>
|
||||
import A from './A.svelte';
|
||||
import B from './B.svelte';
|
||||
|
||||
let Let = A;
|
||||
function update() {
|
||||
Let = B;
|
||||
}
|
||||
|
||||
export let ExportLet = B;
|
||||
|
||||
$: Reactive = random() ? A : B;
|
||||
</script>
|
||||
|
||||
<Let />
|
||||
<ExportLet />
|
||||
<Reactive />
|
||||
<svelte:component this={Let} />
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"generate": true
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
[
|
||||
{
|
||||
"code": "reactive-component",
|
||||
"message": "<Let/> will not be reactive if Let changes. Use <svelte:component this={Let}/> if you want this reactivity.",
|
||||
"pos": 190,
|
||||
"end": {
|
||||
"character": 197,
|
||||
"column": 7,
|
||||
"line": 15
|
||||
},
|
||||
"start": {
|
||||
"character": 190,
|
||||
"column": 0,
|
||||
"line": 15
|
||||
}
|
||||
},
|
||||
{
|
||||
"message": "<ExportLet/> will not be reactive if ExportLet changes. Use <svelte:component this={ExportLet}/> if you want this reactivity.",
|
||||
"code": "reactive-component",
|
||||
"pos": 198,
|
||||
"end": {
|
||||
"character": 211,
|
||||
"column": 13,
|
||||
"line": 16
|
||||
},
|
||||
"start": {
|
||||
"character": 198,
|
||||
"column": 0,
|
||||
"line": 16
|
||||
}
|
||||
},
|
||||
{
|
||||
"message": "<Reactive/> will not be reactive if Reactive changes. Use <svelte:component this={Reactive}/> if you want this reactivity.",
|
||||
"code": "reactive-component",
|
||||
"pos": 212,
|
||||
"end": {
|
||||
"character": 224,
|
||||
"column": 12,
|
||||
"line": 17
|
||||
},
|
||||
"start": {
|
||||
"character": 212,
|
||||
"column": 0,
|
||||
"line": 17
|
||||
}
|
||||
}
|
||||
]
|
Loading…
Reference in new issue