Skip to content

Commit

Permalink
chore: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
paoloricciuti committed Jan 9, 2025
1 parent 3e70c43 commit b2bf429
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script>
const { label = 0, size = 0 } = $props();
const title = $derived(size.toString());
</script>

<p {title}>{label}</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { ok, test } from '../../test';
import { flushSync } from 'svelte';

export default test({
html: `<button></button><p title="0">0</p>`,

async test({ assert, target }) {
const p = target.querySelector('p');
const btn = target.querySelector('button');
flushSync(() => {
btn?.click();
});
assert.equal(p?.innerHTML, '1');
flushSync(() => {
btn?.click();
});
assert.equal(p?.innerHTML, '2');
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<script>
import Component from "./Component.svelte";
let props = $state({
label: 0,
size: 0,
});
let filteredProps = $state();
$effect.pre(() => {
filteredProps = $state.snapshot(props);
});
</script>

<button onclick={()=>props.label++}></button>

<Component {...filteredProps} />

0 comments on commit b2bf429

Please sign in to comment.