|
1 | | -import { test, afterEach } from "@jest/globals"; |
2 | | -import { mount, unmount, tick } from "svelte"; |
| 1 | +import { test, afterEach } from '@jest/globals' |
| 2 | +import { mount, unmount, tick } from 'svelte' |
3 | 3 |
|
4 | | -import Subject from "./legacy.svelte"; |
| 4 | +import Subject from './legacy.svelte' |
5 | 5 |
|
6 | | -let component; |
| 6 | +let component |
7 | 7 |
|
8 | 8 | afterEach(() => { |
9 | | - unmount(component); |
10 | | - component = undefined; |
11 | | -}); |
| 9 | + unmount(component) |
| 10 | + component = undefined |
| 11 | +}) |
12 | 12 |
|
13 | | -test("render", () => { |
| 13 | +test('render', () => { |
14 | 14 | component = mount(Subject, { |
15 | 15 | target: document.body, |
16 | | - props: { name: "alice" }, |
17 | | - }); |
| 16 | + props: { name: 'alice' } |
| 17 | + }) |
18 | 18 |
|
19 | | - const button = document.querySelector("button"); |
| 19 | + const button = document.querySelector('button') |
20 | 20 |
|
21 | | - expect(button).toBeInstanceOf(HTMLButtonElement); |
22 | | -}); |
| 21 | + expect(button).toBeInstanceOf(HTMLButtonElement) |
| 22 | +}) |
23 | 23 |
|
24 | | -test("interaction", async () => { |
| 24 | +test('interaction', async () => { |
25 | 25 | component = mount(Subject, { |
26 | 26 | target: document.body, |
27 | | - props: { name: "alice" }, |
28 | | - }); |
| 27 | + props: { name: 'alice' } |
| 28 | + }) |
29 | 29 |
|
30 | | - const button = document.querySelector("button"); |
| 30 | + const button = document.querySelector('button') |
31 | 31 |
|
32 | | - button.click(); |
33 | | - await tick(); |
| 32 | + button.click() |
| 33 | + await tick() |
34 | 34 |
|
35 | | - const message = document.querySelector("p"); |
| 35 | + const message = document.querySelector('p') |
36 | 36 |
|
37 | | - expect(message.textContent).toMatch(/hello alice/iu); |
38 | | -}); |
| 37 | + expect(message.textContent).toMatch(/hello alice/iu) |
| 38 | +}) |
0 commit comments