/
publish-tagging.test.js
53 lines (40 loc) · 1.65 KB
/
publish-tagging.test.js
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
"use strict";
// local modules _must_ be explicitly mocked
jest.mock("../lib/get-packages-without-license");
jest.mock("../lib/verify-npm-package-access");
jest.mock("../lib/verify-npm-registry");
// FIXME: better mock for version command
jest.mock("../../version/lib/git-push");
jest.mock("../../version/lib/is-anything-committed");
jest.mock("../../version/lib/is-behind-upstream");
// mocked modules
const collectUpdates = require("@lerna/collect-updates");
const npmDistTag = require("@lerna/npm-dist-tag");
const npmPublish = require("@lerna/npm-publish");
// helpers
const initFixture = require("@lerna-test/init-fixture")(__dirname);
// test command
const lernaPublish = require("@lerna-test/command-runner")(require("../command"));
test("publish --npm-tag", async () => {
const cwd = await initFixture("normal");
collectUpdates.setUpdated(cwd, "package-3");
await lernaPublish(cwd)("--npm-tag", "custom");
expect(npmPublish.registry.get("package-3")).toBe("custom");
expect(npmDistTag.check).not.toBeCalled();
});
test("publish --temp-tag", async () => {
const cwd = await initFixture("normal");
collectUpdates.setUpdated(cwd, "package-4");
await lernaPublish(cwd)("--temp-tag", "--registry", "test-registry");
expect(npmPublish.registry.get("package-4")).toBe("lerna-temp");
expect(npmDistTag.remove).lastCalledWith(
expect.objectContaining({ name: "package-4" }),
"lerna-temp",
expect.objectContaining({ registry: "test-registry" })
);
expect(npmDistTag.add).lastCalledWith(
expect.objectContaining({ name: "package-4", version: "1.0.1" }),
"latest",
expect.objectContaining({ registry: "test-registry" })
);
});