-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.test.ts
87 lines (85 loc) · 3.9 KB
/
main.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import { assert, assertStrictEquals } from "https://deno.land/[email protected]/testing/asserts.ts";
import { getProductName, RELEASE_RULE, URL_RULES } from "./lib.ts";
Deno.test("getProductName - {name} {ver}リリース", () => {
const name = getProductName([
{
date: "2021-10-17T15:48:46.120Z",
title: "Nuxt - Introducing Nuxt 3 Beta",
url: "https://nuxtjs.org/announcements/nuxt3-beta/",
content:
"Nuxt 3 betaリリース。\nVue 3とViteへの対応。\n新しいサーバエンジンのNitro Engineを導入することで、通常のNode.jsサーバ、Serverless、Service Wo...",
tags: ["Vue", "Next.js", "ReleaseNote"],
relatedLinks: [],
},
{
date: "2022-04-24T12:46:38.269Z",
title: "Nuxt - Announcing Nuxt 3 Release Candidate",
url: "https://nuxtjs.org/announcements/nuxt3-rc/",
content: "Nuxt 3 RCリリース。\nVue 3、TypeScript、Viteのサポート。\nサーバーエンジンのNitroとポータブルな出力の対応など",
tags: ["Vue", "library", "ReleaseNote"],
relatedLinks: [],
},
]);
assertStrictEquals(name, "Nuxt");
});
Deno.test("getProductName - {name} {ver}-alpha|betaリリース", () => {
const name = getProductName([
{
date: "2022-01-29T14:18:59.905Z",
title: "Release v2.0.0 · nightwatchjs/nightwatch",
url: "https://github.com/nightwatchjs/nightwatch/releases/tag/v2.0.0",
content:
"Nightwatch 2.0リリース。\nPlugin APIの追加、`nightwatch.conf.cjs`のサポート、chai expectのアップデート。\nAssertion/Element C...",
tags: ["E2E", "testing", "library", "ReleaseNote"],
relatedLinks: [],
},
]);
assertStrictEquals(name, "Nightwatch");
});
Deno.test("getProductName - {name} {ver}-rc.{ver}リリース", () => {
const name = getProductName([
{
date: "2021-09-04T12:29:57.045Z",
title: "jQuery UI 1.13.0-rc.2 released | jQuery UI Blog",
url: "https://blog.jqueryui.com/2021/09/jquery-ui-1-13-0-rc-2-released/",
content:
"jQuery UI 1.13.0-rc.2リリース。\n5年ぶりとなるリリース。\n最近jQueryとの互換性を改善する目的のリリースであるため、非互換な変更は含まない。",
tags: ["jQuery", "UI", "library", "ReleaseNote"],
relatedLinks: [],
},
]);
assertStrictEquals(name, "jQuery UI");
});
Deno.test("URL_RULES data", async (t) => {
for (const rule of URL_RULES) {
const tests = rule.tests ?? [];
for (const test of tests) {
await t.step(test.input + " → " + test.output, () => {
const matchRule = rule.match?.(test.input);
if (test.output === undefined) {
assertStrictEquals(matchRule, null);
return;
}
assert(matchRule, "should be matched: " + JSON.stringify(rule));
const result = rule.url?.({ url: test.input, match: matchRule });
assertStrictEquals(result, test.output);
});
}
}
});
Deno.test("RELEASE_RULE data", async (t) => {
for (const rule of RELEASE_RULE) {
for (const test of rule.tests) {
await t.step(test.input + " → " + test.output, () => {
const matchRule = rule.matchVersion?.(test.input);
if (test.output === undefined) {
assertStrictEquals(matchRule, null);
return;
}
assert(matchRule, "should be matched: " + JSON.stringify(rule));
const result = rule.version?.({ url: test.input, match: matchRule });
assertStrictEquals(result, test.output);
});
}
}
});