-
Notifications
You must be signed in to change notification settings - Fork 5
/
componentDetection.test.ts
53 lines (48 loc) · 1.59 KB
/
componentDetection.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
import ComponentDetection from "./componentDetection";
import fs from "fs";
test("Downloads CLI", async () => {
await ComponentDetection.downloadLatestRelease();
expect(fs.existsSync(ComponentDetection.componentDetectionPath));
});
test("Runs CLI", async () => {
await ComponentDetection.downloadLatestRelease();
await ComponentDetection.runComponentDetection("./test");
expect(fs.existsSync(ComponentDetection.outputPath));
});
test("Parses CLI output", async () => {
await ComponentDetection.downloadLatestRelease();
await ComponentDetection.runComponentDetection("./test");
var manifests = await ComponentDetection.getManifestsFromResults();
expect(manifests?.length == 2);
});
describe("ComponentDetection.makePackageUrl", () => {
test("returns a valid package url from saturated object", () => {
const packageUrl = ComponentDetection.makePackageUrl({
Scheme: "pkg",
Type: "npm",
Namespace: "github",
Name: "component-detection-action",
Version: "0.0.2",
Qualifiers: {
arch: "amd64",
os: "linux",
},
});
expect(packageUrl).toBe(
"pkg:npm/github/[email protected]?arch=amd64&os=linux"
);
});
test("returns valid package url without dangling ? with empty qualifers", () => {
const packageUrl = ComponentDetection.makePackageUrl({
Scheme: "pkg",
Type: "npm",
Namespace: "github",
Name: "component-detection-action",
Version: "0.0.2",
Qualifiers: { },
});
expect(packageUrl).toBe(
"pkg:npm/github/[email protected]"
);
});
});