-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest.ts
55 lines (48 loc) · 1.23 KB
/
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
import {
assertEquals,
assertThrows,
} from "https://deno.land/[email protected]/testing/asserts.ts";
import { driveLink } from "./mod.ts";
Deno.test("Main", () => {
assertEquals(
driveLink(
"https://drive.google.com/file/d/1DvRH-yk1z0HVBK-EmiQeJ_VVh5eHwQXh/view?usp=sharing",
),
"https://drive.google.com/uc?export=download&id=1DvRH-yk1z0HVBK-EmiQeJ_VVh5eHwQXh",
);
assertEquals(
driveLink("1DvRH-yk1z0HVBK-EmiQeJ_VVh5eHwQXh"),
"https://drive.google.com/uc?export=download&id=1DvRH-yk1z0HVBK-EmiQeJ_VVh5eHwQXh",
);
assertEquals(
driveLink(
"https://drive.google.com/file/d/1Px8bePd7pFSz5r6bTA7GKN9HloCzMfFk/view?usp=sharing",
{ apiKey: "driveLink" },
),
"https://www.googleapis.com/drive/v3/files/1Px8bePd7pFSz5r6bTA7GKN9HloCzMfFk?alt=media&key=driveLink",
);
});
Deno.test("Errors", () => {
assertThrows(
() => {
// @ts-ignore: It should throw an error.
driveLink(3);
},
Error,
"Invalid URL provided.",
);
assertThrows(
() => {
driveLink("https://ultirequiem.com");
},
Error,
"Invalid URL provided.",
);
assertThrows(
() => {
driveLink("url", { apiKey: "$$$" });
},
Error,
"Invalid API key provided.",
);
});