Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
trueadm committed Oct 25, 2024
1 parent 40c4107 commit 37d0127
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { flushSync } from 'svelte';
import { test } from '../../test';

export default test({
async test({ assert, target }) {
const b1 = target.querySelector('button');

let err = '';
window.addEventListener('error', (e) => {
e.preventDefault();
err = e.message;
});

b1?.click();
await Promise.resolve();
flushSync();

assert.throws(() => {
throw err;
}, /Test/);
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<script>
const promise = new Promise((res, rej) => {
rej(new Error('Test'));
})
let toggle = $state(false);
</script>

<button onclick={() => toggle = !toggle}>toggle</button>

{#if toggle}
{#await promise}{/await}
{/if}

0 comments on commit 37d0127

Please sign in to comment.