-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.ts
39 lines (37 loc) · 827 Bytes
/
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
import { MATCHER } from "./index";
const cases = [
{
scope: "denoland",
repo: "deno_std",
branch: "v0.2.8",
rest: "/examples/gist.ts"
},
{
scope: "denoland",
repo: "deno_std",
branch: "master",
rest: "/examples/gist.ts"
},
{
scope: "denoland",
repo: "deno_std",
branch: "",
rest: "/examples/gist.ts"
}
];
test("matcher", () => {
for (const c of cases) {
const url = `/${c.scope}/${c.repo}${c.branch ? `@${c.branch}` : ""}${
c.rest
}`;
const [, scope, repo, versionSpecified, branch, rest] = MATCHER.exec(url);
expect(
() =>
scope === c.scope &&
repo === c.repo &&
(versionSpecified === undefined || versionSpecified === "@") &&
branch === c.branch &&
rest === c.rest
).toBeTruthy();
}
});