-
Notifications
You must be signed in to change notification settings - Fork 494
/
publishPackages.test.ts
49 lines (40 loc) 路 1.14 KB
/
publishPackages.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
import fixtures from "fixturez";
import publishPackages from "../publishPackages";
import * as npmUtils from "../npm-utils";
import { getPackages } from "@manypkg/get-packages";
import { silenceLogsInBlock } from "@changesets/test-utils";
jest.mock("../npm-utils");
jest.mock("is-ci", () => true);
const f = fixtures(__dirname);
describe("publishPackages", () => {
silenceLogsInBlock();
let cwd: string;
beforeEach(async () => {
cwd = await f.copy("simple-project");
// @ts-ignore
npmUtils.infoAllow404.mockImplementation(() => ({
published: false,
pkgInfo: {
version: "1.0.0"
}
}));
// @ts-ignore
npmUtils.publish.mockImplementation(() => ({
published: true
}));
});
afterEach(() => {
jest.clearAllMocks();
});
describe("when isCI", () => {
it("does not call out to npm to see if otp is required", async () => {
await publishPackages({
packages: (await getPackages(cwd)).packages,
access: "public",
preState: undefined,
trackPrivatePackages: true
});
expect(npmUtils.getTokenIsRequired).not.toHaveBeenCalled();
});
});
});