blob: 6e0e65211ca5a8fd7eae0704f5eeb84b987ea132 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
// async onsubmit(event)
//
// Example:
/* */
import { flushSync, mount, unmount } from 'svelte';
import { expect, test } from 'vitest';
import ChangePassword from '$lib/components/ChangePassword.svelte';
test('ChangePassword', () => {
// Instantiate the component using Svelte's `mount` API
const component = mount(ChangePassword, {
target: document.body, // `document` exists because of jsdom
props: { initial: 0 }
});
expect(document.body.innerHTML).toBe('<button>0</button>');
// Click the button, then flush the changes so you can synchronously write expectations
document.body.querySelector('button').click();
flushSync();
expect(document.body.innerHTML).toBe('<button>1</button>');
// Remove the component from the DOM
unmount(component);
});
/* */
|