From 0938c0e64c053f3ec2a6f843f3a1aa6548e2fe98 Mon Sep 17 00:00:00 2001 From: lshadler Date: Mon, 25 Oct 2021 14:34:04 -0400 Subject: [PATCH] test: add unit test for maintenance npm calc --- plugins/npm/__tests__/npm.test.ts | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/plugins/npm/__tests__/npm.test.ts b/plugins/npm/__tests__/npm.test.ts index a42b3b013..58c3908eb 100644 --- a/plugins/npm/__tests__/npm.test.ts +++ b/plugins/npm/__tests__/npm.test.ts @@ -398,6 +398,42 @@ describe("getPreviousVersion", () => { expect(await hooks.getPreviousVersion.promise()).toBe("0.1.2"); }); + + test("should ignore greatest published monorepo package in maintenance mode", async () => { + execPromise.mockClear() + mockFs({ + "lerna.json": ` + { + "name": "test", + "version": "1.5.0" + } + `, + ...monorepoPackagesOnFs, + }); + const plugin = new NPMPlugin(); + const hooks = makeHooks(); + + // isMonorepo + monorepoPackages.mockReturnValueOnce(monorepoPackagesResult); + // published version of test package + execPromise.mockReturnValueOnce("2.1.0"); + + jest.spyOn(Auto, 'getCurrentBranch').mockReturnValueOnce('major-2') + + + plugin.apply({ + config: { prereleaseBranches: ["next"], versionBranches: 'major-' }, + hooks, + remote: "origin", + baseBranch: "main", + logger: dummyLog(), + prefixRelease: (str) => str, + } as Auto.Auto); + + + expect(await hooks.getPreviousVersion.promise()).toBe("1.5.0"); + expect(execPromise).not.toHaveBeenCalled() + }); }); test("should use string semver if no published package", async () => {