Skip to content
This repository was archived by the owner on Apr 13, 2025. It is now read-only.

Commit 67ee171

Browse files
committed
Add tests for getSubPackage and diffPackage with dashboard
1 parent b0f2983 commit 67ee171

File tree

4 files changed

+27
-5
lines changed

4 files changed

+27
-5
lines changed

test/install/production.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { vol } from "memfs";
22
import * as path from "path";
3-
import { corePkg, nodecgIODir, twitchChatPkg, validProdInstall } from "../testUtils";
3+
import { corePkg, dashboardPkg, nodecgIODir, twitchChatPkg, validProdInstall } from "../testUtils";
44
import { diffPackages, installPackages, removePackages, validateInstall } from "../../src/install/production";
55
import * as installation from "../../src/installation";
66
import * as fsUtils from "../../src/fsUtils";
@@ -45,6 +45,13 @@ describe("diffPackages", () => {
4545
expect(pkgRemove).toStrictEqual([]);
4646
expect(pkgInstall).toStrictEqual([]);
4747
});
48+
49+
test("should install dashboard (sub pkg) if upgrading core", async () => {
50+
// dashboard not modified, but should still be installed because it is in core and core gets upgraded
51+
const { pkgInstall, pkgRemove } = diffPackages([corePkg2, dashboardPkg], [corePkg, dashboardPkg]);
52+
expect(pkgRemove).toStrictEqual([corePkg]);
53+
expect(pkgInstall).toStrictEqual([corePkg2, dashboardPkg]);
54+
});
4855
});
4956

5057
describe("removePackages", () => {

test/install/prompt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe("getCompatibleVersions", () => {
2525
});
2626

2727
describe("buildPackageList", () => {
28-
const ver = "0.1.0";
28+
const ver = "0.1";
2929
const testSvcName = "testSvc";
3030
const testSvcPkgName = `nodecg-io-${testSvcName}`;
3131
const mock = jest.spyOn(npm, "getHighestPatchVersion").mockResolvedValue("0.1.1");

test/npm/pkgManagement.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createFsFromVolume, vol } from "memfs";
2-
import { createNpmSymlinks, removeNpmPackage, runNpmInstall } from "../../src/npm";
3-
import { tempDir, corePkg, fsRoot } from "../testUtils";
2+
import { createNpmSymlinks, getSubPackages, removeNpmPackage, runNpmInstall } from "../../src/npm";
3+
import { tempDir, corePkg, fsRoot, twitchChatPkg, dashboardPkg } from "../testUtils";
44
import * as fsUtils from "../../src/fsUtils";
55
import * as path from "path";
66

@@ -45,3 +45,13 @@ describe("removeNpmPackage", () => {
4545
expect(spy).toHaveBeenCalled();
4646
});
4747
});
48+
49+
describe("getSubPackages", () => {
50+
test("should return empty list if no packages are inside the passed package", async () => {
51+
expect(getSubPackages([corePkg, twitchChatPkg], corePkg)).toStrictEqual([]);
52+
});
53+
54+
test("should return dashboard to be inside core", async () => {
55+
expect(getSubPackages([corePkg, dashboardPkg], corePkg)).toStrictEqual([dashboardPkg]);
56+
});
57+
});

test/testUtils.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as temp from "temp";
2-
import { corePackage } from "../src/install/nodecgIOVersions";
2+
import { corePackage, dashboardPackage, dashboardPath } from "../src/install/nodecgIOVersions";
33
import * as path from "path";
44
import { DevelopmentInstallation, ProductionInstallation } from "../src/installation";
55

@@ -21,6 +21,11 @@ export const twitchChatPkg = {
2121
path: "nodecg-io-twitch-chat",
2222
version: "0.1.0",
2323
};
24+
export const dashboardPkg = {
25+
name: dashboardPackage,
26+
path: dashboardPath,
27+
version: "0.1.0",
28+
};
2429
export const nodecgExampleConfig = {
2530
bundles: {
2631
paths: ["some-custom-bundle-dir"],

0 commit comments

Comments
 (0)