-
-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathwatcher.test.ts
69 lines (60 loc) · 1.48 KB
/
watcher.test.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
// Copyright 2020-2021 the denosaurs team. All rights reserved. MIT license.
import { assert } from "../test_deps.ts";
import { Watcher, WatcherConfig } from "./watcher.ts";
Deno.test({
name: "watcher | exts",
fn(): void {
const config: WatcherConfig = {
paths: [Deno.cwd()],
interval: 350,
exts: ["json"],
skip: [],
match: [],
};
const watcher = new Watcher(config);
assert(
!watcher.isWatched("src/args.ts"),
"should not match because of extension",
);
config.exts = [];
config.skip = ["src/*"];
watcher.reload();
assert(
!watcher.isWatched("src/args.ts"),
"should not match because parent dir is skipped",
);
config.exts = [];
config.skip = [];
config.match = ["lib/*"];
watcher.reload();
assert(
!watcher.isWatched("src/args.ts"),
"should not match because parent dir is not matched",
);
config.exts = [".ts"];
config.skip = [];
config.match = ["**"];
watcher.reload();
assert(
watcher.isWatched("src/args.ts"),
"should match because of extensions",
);
},
});
Deno.test({
name: "watcher | skip",
fn(): void {
const config: WatcherConfig = {
paths: [Deno.cwd()],
interval: 350,
exts: [],
skip: ["src/*"],
match: [],
};
const watcher = new Watcher(config);
assert(
!watcher.isWatched("src/args.ts"),
"should not match because parent dir is skipped",
);
},
});