-
Notifications
You must be signed in to change notification settings - Fork 3
/
mod_test.ts
58 lines (44 loc) · 1.31 KB
/
mod_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
import {
assertEquals,
assertThrows,
} from "https://deno.land/std@0.218.0/testing/asserts.ts";
import { _parsePath, extname } from "./mod.ts";
Deno.test("extname", () => {
assertEquals(extname("test.py"), ".py");
assertEquals(extname("main/main.go"), ".go");
assertEquals(extname("../add_params/mod.ts"), ".ts");
assertEquals(extname({ path: "mod.ts", leadingPeriod: false }), "ts");
assertEquals(extname({ path: "App.js", leadingPeriod: true }), ".js");
assertThrows(() => {
extname({ path: "/", leadingPeriod: false });
});
assertThrows(() => {
extname({ path: "tests/", leadingPeriod: false });
});
assertThrows(() => {
extname({ path: "App", leadingPeriod: false });
});
assertEquals(extname({ path: "data.gz.arg", leadingPeriod: true }), ".arg");
});
Deno.test("_parsePath", () => {
assertEquals(_parsePath("/path/to/file.ext"), {
path: "/path/to/file.ext",
leadingPeriod: true,
});
assertEquals(_parsePath({ path: "hey.txt", leadingPeriod: false }), {
path: "hey.txt",
leadingPeriod: false,
});
assertThrows(() => {
//@ts-ignore: Should throw
_parsePath(34);
});
assertThrows(() => {
//@ts-ignore: Should throw
_parsePath({});
});
assertThrows(() => {
//@ts-ignore: Should throw
_parsePath({ leadingPeriod: false });
});
});