forked from QwikDev/qwik
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathe2e.computed.spec.ts
90 lines (79 loc) · 2.67 KB
/
e2e.computed.spec.ts
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import { test, expect } from "@playwright/test";
test.describe("slot", () => {
function tests() {
test("should implement basic computed values", async ({ page }) => {
const result = page.locator(".result");
const increment = page.locator("#increment");
await expect(result).toHaveText([
"count: 0",
"double: 0",
"plus3: 3",
"triple: 9",
"sum: 12",
]);
await increment.click();
await expect(result).toHaveText([
"count: 1",
"double: 2",
"plus3: 5",
"triple: 15",
"sum: 22",
]);
await increment.click();
await expect(result).toHaveText([
"count: 2",
"double: 4",
"plus3: 7",
"triple: 21",
"sum: 32",
]);
});
test("issue 3482", async ({ page }) => {
const button = page.locator("#issue-3482-button");
const div = page.locator("#issue-3482-div");
const classEl = page.locator("#issue-3482-class");
const datanuEl = page.locator("#issue-3482-datanu");
await expect(div).toHaveAttribute("class", "class-0");
await expect(div).toHaveAttribute("data-nu", "0");
await expect(classEl).toHaveText("class: class-0");
await expect(datanuEl).toHaveText("data-nu: 0");
await button.click();
await expect(div).toHaveAttribute("class", "class-1");
await expect(div).toHaveAttribute("data-nu", "1");
await expect(classEl).toHaveText("class: class-1");
await expect(datanuEl).toHaveText("data-nu: 1");
await button.click();
await expect(div).toHaveAttribute("class", "class-2");
await expect(div).toHaveAttribute("data-nu", "2");
await expect(classEl).toHaveText("class: class-2");
await expect(datanuEl).toHaveText("data-nu: 2");
});
test("issue 3488", async ({ page }) => {
const result = page.locator("#issue-3488-result");
const button = page.locator("#issue-3488-button");
await expect(result).toHaveText("class-0");
await button.click();
await expect(result).toHaveText("class-1");
await button.click();
await expect(result).toHaveText("class-2");
});
}
test.beforeEach(async ({ page }) => {
await page.goto("/e2e/computed");
page.on("pageerror", (err) => expect(err).toEqual(undefined));
page.on("console", (msg) => {
if (msg.type() === "error") {
expect(msg.text()).toEqual(undefined);
}
});
});
tests();
test.describe("client rerender", () => {
test.beforeEach(async ({ page }) => {
const rerender = page.locator("#rerender");
await rerender.click();
await page.waitForTimeout(100);
});
tests();
});
});