Skip to content

Commit e07757e

Browse files
committed
Update tests
1 parent 12357dd commit e07757e

File tree

4 files changed

+19
-15
lines changed

4 files changed

+19
-15
lines changed

componentDetection.test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
import {downloadLatestRelease, getManifestsFromResults, runComponentDetection} from './componentDetection';
1+
import ComponentDetection from './componentDetection';
2+
import fs from 'fs';
23

34
test('Downloads CLI', async () => {
4-
downloadLatestRelease();
5+
ComponentDetection.downloadLatestRelease();
6+
expect(fs.existsSync(ComponentDetection.componentDetectionPath));
57
});
68

79
test('Runs CLI', async () => {
8-
runComponentDetection('./test');
10+
ComponentDetection.runComponentDetection('./test');
11+
expect(fs.existsSync(ComponentDetection.outputPath));
912
});
1013

1114
test('Parses CLI output', async () => {
12-
getManifestsFromResults();
15+
var manifests = await ComponentDetection.getManifestsFromResults();
16+
expect(manifests?.length == 2);
1317
});

componentDetection.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import { unmockedModulePathPatterns } from './jest.config'
1818
dotenv.config();
1919

2020
export default class ComponentDetection {
21-
protected static componentDetectionPath = './component-detection';
22-
protected static outputPath = './output.json';
21+
public static componentDetectionPath = './component-detection';
22+
public static outputPath = './output.json';
2323

2424
// This is the default entry point for this class.
2525
static async scanAndGetManifests(path: string): Promise<Manifest[] | undefined> {
@@ -28,7 +28,7 @@ export default class ComponentDetection {
2828
return await this.getManifestsFromResults();
2929
}
3030
// Get the latest release from the component-detection repo, download the tarball, and extract it
31-
private static async downloadLatestRelease() {
31+
public static async downloadLatestRelease() {
3232
try {
3333
core.debug("Downloading latest release");
3434
const downloadURL = await this.getLatestReleaseURL();
@@ -45,7 +45,7 @@ export default class ComponentDetection {
4545
}
4646

4747
// Run the component-detection CLI on the path specified
48-
private static async runComponentDetection(path: string) {
48+
public static async runComponentDetection(path: string) {
4949
core.info("Running component-detection");
5050

5151
try {
@@ -64,7 +64,7 @@ export default class ComponentDetection {
6464
return parameters;
6565
}
6666

67-
private static async getManifestsFromResults(): Promise<Manifest[]| undefined> {
67+
public static async getManifestsFromResults(): Promise<Manifest[]| undefined> {
6868
core.info("Getting manifests from results");
6969
// Parse the result file and add the packages to the package cache
7070
const packageCache = new PackageCache();

dist/componentDetection.d.ts

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)