mirror of https://github.com/sveltejs/svelte
parent
59f374c3cf
commit
23e0803711
@ -1,6 +1,6 @@
|
||||
<script>
|
||||
let a = $state(0);
|
||||
let b = $derived({ a });
|
||||
let {b} = $derived({ a });
|
||||
</script>
|
||||
|
||||
<input type="number" bind:value={b} />
|
@ -0,0 +1,19 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: `<button>0</button><button>0</button>`,
|
||||
|
||||
test({ assert, target }) {
|
||||
const [btn1, btn2] = target.querySelectorAll('button');
|
||||
|
||||
flushSync(() => btn1.click());
|
||||
assert.htmlEqual(target.innerHTML, `<button>1</button><button>1</button>`);
|
||||
|
||||
flushSync(() => btn2.click());
|
||||
assert.htmlEqual(target.innerHTML, `<button>1</button><button>2</button>`);
|
||||
|
||||
flushSync(() => btn1.click());
|
||||
assert.htmlEqual(target.innerHTML, `<button>2</button><button>2</button>`);
|
||||
}
|
||||
});
|
@ -0,0 +1,10 @@
|
||||
<script>
|
||||
class Instance {
|
||||
a = $state(0);
|
||||
b = $state.link(this.a);
|
||||
}
|
||||
const instance = new Instance();
|
||||
</script>
|
||||
|
||||
<button onclick={() => instance.a++}>{instance.a}</button>
|
||||
<button onclick={() => instance.b++}>{instance.b}</button>
|
@ -0,0 +1,19 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: `<button>0</button><button>0</button>`,
|
||||
|
||||
test({ assert, target }) {
|
||||
const [btn1, btn2] = target.querySelectorAll('button');
|
||||
|
||||
flushSync(() => btn1.click());
|
||||
assert.htmlEqual(target.innerHTML, `<button>1</button><button>1</button>`);
|
||||
|
||||
flushSync(() => btn2.click());
|
||||
assert.htmlEqual(target.innerHTML, `<button>1</button><button>2</button>`);
|
||||
|
||||
flushSync(() => btn1.click());
|
||||
assert.htmlEqual(target.innerHTML, `<button>2</button><button>2</button>`);
|
||||
}
|
||||
});
|
@ -0,0 +1,7 @@
|
||||
<script>
|
||||
let a = $state(0);
|
||||
let b = $derived(a);
|
||||
</script>
|
||||
|
||||
<button onclick={() => a++}>{a}</button>
|
||||
<button onclick={() => b++}>{b}</button>
|
Loading…
Reference in new issue