This repository has been archived by the owner on Jul 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutils.test.ts
80 lines (66 loc) · 2.11 KB
/
utils.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
// Import Node.js Dependencies
import { describe, test } from "node:test";
import assert from "node:assert";
// Import Internal Dependencies
import { checkEveryTruthy, checkSomeTruthy, checkSpdx, createSpdxLink } from "../src/utils.js";
describe("Check everytruthy", () => {
test("check a single true is true", () => {
assert.equal(checkEveryTruthy(true), true);
});
test("check multiple true booleans are true", () => {
assert.equal(checkEveryTruthy(true, true, true), true);
});
test("check that a single false is false", () => {
assert.equal(checkEveryTruthy(false), false);
});
test("ensure that one false will result in a false return", () => {
assert.equal(checkEveryTruthy(true, false), false);
});
});
describe("check someTruthy", () => {
test("check a single true is true", () => {
assert.equal(checkSomeTruthy(true), true);
});
test("check multiple true booleans are true", () => {
assert.equal(checkSomeTruthy(true, true, true), true);
});
test("check that a single false is false", () => {
assert.equal(checkSomeTruthy(false), false);
});
test("ensure that one false will result in a true return", () => {
assert.equal(checkSomeTruthy(true, false), true);
});
test("create an MIT SPDX link", () => {
const link = createSpdxLink("MIT");
assert.strictEqual(link, "https://spdx.org/licenses/MIT.html#licenseText");
});
});
describe("checkSpdx", () => {
test("test with MIT license", () => {
const mitLicense = checkSpdx("MIT");
assert.deepEqual(mitLicense, {
osi: true,
fsf: true,
fsfAndOsi: true,
includesDeprecated: false
});
});
test("test with a deprecated license", () => {
const deprecatedLicense = checkSpdx("AGPL-1.0");
assert.deepEqual(deprecatedLicense, {
osi: false,
fsf: true,
fsfAndOsi: false,
includesDeprecated: true
});
});
test("test with a broken license", () => {
const brokenLicense = checkSpdx("wrong");
assert.deepEqual(brokenLicense, {
osi: false,
fsf: false,
fsfAndOsi: false,
includesDeprecated: false
});
});
});