generated from lifeart/els-a11y-addon
-
Notifications
You must be signed in to change notification settings - Fork 1
/
utils.test.js
68 lines (66 loc) · 1.91 KB
/
utils.test.js
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
const {
normalizeToAngleBracketComponent,
waitForFileNameContains,
watcherFn,
hasMatchFunctions,
} = require("./utils");
describe("normalizeToAngleBracketComponent", () => {
it("ok", () => {
expect(normalizeToAngleBracketComponent("foo-bar")).toBe("FooBar");
expect(normalizeToAngleBracketComponent("foo-bar/baz-boo")).toBe(
"FooBar::BazBoo"
);
expect(normalizeToAngleBracketComponent("foo.boo")).toBe("foo.boo");
});
});
describe("waitForFileNameContains", () => {
it("ok", async () => {
try {
const waiter = waitForFileNameContains("foo", 100);
expect(hasMatchFunctions()).toBe(true);
watcherFn("fos", 1);
expect(hasMatchFunctions()).toBe(true);
watcherFn("foo", 1);
expect(hasMatchFunctions()).toBe(false);
await waiter;
} catch (e) {
expect(e.toString()).toBe(null);
}
});
it("supports win paths", async () => {
try {
const waiter = waitForFileNameContains("foo/bar", 100);
expect(hasMatchFunctions()).toBe(true);
watcherFn("foo\\bar", 1);
expect(hasMatchFunctions()).toBe(false);
await waiter;
} catch (e) {
expect(e.toString()).toBe(null);
}
});
it("failing", async () => {
try {
const waiter = waitForFileNameContains("foo", 100);
watcherFn("foz", 2);
expect(hasMatchFunctions()).toBe(true);
await waiter;
} catch (e) {
expect(hasMatchFunctions()).toBe(false);
}
});
it("removing", async () => {
const waiter = waitForFileNameContains("foo", 100);
expect(hasMatchFunctions()).toBe(true);
watcherFn("foo", 1);
expect(hasMatchFunctions()).toBe(false);
await waiter;
});
it("has default timeout", async () => {
const waiter = waitForFileNameContains("foo");
expect(hasMatchFunctions()).toBe(true);
watcherFn("foo", 1);
expect(hasMatchFunctions()).toBe(false);
await waiter;
expect(2).toBe(2);
});
});