Skip to content
This repository was archived by the owner on Jun 3, 2023. It is now read-only.

Commit 61a44b8

Browse files
committed
test: fix imports
1 parent c55c90c commit 61a44b8

File tree

3 files changed

+13
-38
lines changed

3 files changed

+13
-38
lines changed

__tests__/commit.spec.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import "./mocks.js"
22
import { ReportSteps } from "../bin/helpers/constants.js"
3-
import {
4-
getCommitCmd,
5-
getTagCmd,
6-
getPushCmd,
7-
} from "../bin/helpers/git-commands.js"
3+
import { getCommitCmd, getTagCmd, getPushCmd } from "../bin/helpers/commands.js"
84
import { setVersionToString } from "../bin/helpers/transformers.js"
95
import { reportCmd } from "../bin/helpers/cmd.js"
106
import { runCommit } from "../bin/modules/commit.js"

__tests__/increment.spec.js

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
import "./mocks.js"
22
import fs from "fs"
33
import path from "path"
4-
import { pkgReporter, exitWithError } from "../bin/helpers/reporter.js"
4+
import { report, exitWithError } from "../bin/helpers/reporter.js"
55
import { cmd } from "../bin/helpers/cmd.js"
6-
import { getVersionCommand } from "../bin/helpers/npm-commands.js"
6+
import { getVersionCommand } from "../bin/helpers/commands.js"
77
import { runIncrement } from "../bin/modules/increment.js"
88

99
jest.mock("../bin/helpers/cmd.js", () => ({
1010
cmd: jest.fn(),
1111
}))
1212
jest.mock("../bin/helpers/reporter.js", () => ({
1313
exitWithError: jest.fn(),
14-
pkgReporter: {
15-
info: jest.fn(),
16-
start: jest.fn(),
17-
succeed: jest.fn(),
18-
},
14+
report: jest.fn(),
1915
}))
2016

2117
const packageNames = ["@test/one", "@test/two"]
@@ -65,11 +61,7 @@ describe("runIncrement()", () => {
6561
// When
6662
await runIncrement(config, entryOne)
6763
// Then
68-
expect(cmd).toBeCalledWith(
69-
command,
70-
expect.objectContaining(config),
71-
pkgReporter
72-
)
64+
expect(cmd).toBeCalledWith(command, expect.objectContaining(config), true)
7365
})
7466

7567
it("sets new package content", async () => {
@@ -96,9 +88,7 @@ describe("runIncrement()", () => {
9688
// When
9789
await runIncrement(dryConfig, entryOne)
9890
// Then
99-
expect(pkgReporter.info).toBeCalledWith(
100-
`fs.writeFileSync(path.resolve(dir, "package.json"), newPkgJson, "utf8")`
101-
)
91+
expect(report).toBeCalled()
10292
})
10393

10494
it("prints write command if verbose", async () => {
@@ -107,9 +97,7 @@ describe("runIncrement()", () => {
10797
// When
10898
await runIncrement(verbConfig, entryOne)
10999
// Then
110-
expect(pkgReporter.info).toBeCalledWith(
111-
`fs.writeFileSync(path.resolve(dir, "package.json"), newPkgJson, "utf8")`
112-
)
100+
expect(report).toBeCalled()
113101
})
114102

115103
it("does not write to package.json if dry run", async () => {

__tests__/publish.spec.js

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
11
import "./mocks.js"
22
import path from "path"
3-
import { getAddCommand } from "../bin/helpers/git-commands.js"
3+
import { getAddCommand, getPublishCommand } from "../bin/helpers/commands.js"
44
import { cmd } from "../bin/helpers/cmd.js"
5-
import { pkgReporter } from "../bin/helpers/reporter.js"
6-
import { getPublishCommand } from "../bin/helpers/npm-commands.js"
75
import { runPublish } from "../bin/modules/publish.js"
86

97
jest.mock("../bin/helpers/cmd.js", () => ({
108
cmd: jest.fn(),
119
}))
1210

13-
jest.mock("../bin/helpers/reporter.js", () => ({
14-
pkgReporter: {
15-
start: jest.fn(),
16-
succeed: jest.fn(),
17-
},
18-
}))
19-
2011
const entry = {
2112
name: "@test/one",
2213
dir: path.resolve(process.cwd(), "packages/one"),
@@ -50,7 +41,7 @@ describe("runPublish()", () => {
5041
// When
5142
await runPublish(baseConfig, entry)
5243
// Then
53-
expect(cmd).toBeCalledWith(getAddCommand(), baseConfig, pkgReporter)
44+
expect(cmd).toBeCalledWith(getAddCommand(), baseConfig, true)
5445
})
5546

5647
it("publishes package", async () => {
@@ -60,7 +51,7 @@ describe("runPublish()", () => {
6051
expect(cmd).toBeCalledWith(
6152
getPublishCommand(entry.name, "latest"),
6253
baseConfig,
63-
pkgReporter
54+
true
6455
)
6556
})
6657

@@ -83,7 +74,7 @@ describe("runPublish()", () => {
8374
expect(cmd).toBeCalledWith(
8475
getPublishCommand(entry.name, "next"),
8576
config,
86-
pkgReporter
77+
true
8778
)
8879
})
8980

@@ -99,7 +90,7 @@ describe("runPublish()", () => {
9990
expect(cmd).toBeCalledWith(
10091
getPublishCommand(entry.name, "alpha"),
10192
config,
102-
pkgReporter
93+
true
10394
)
10495
})
10596

@@ -115,7 +106,7 @@ describe("runPublish()", () => {
115106
expect(cmd).toBeCalledWith(
116107
getPublishCommand(entry.name, "beta"),
117108
config,
118-
pkgReporter
109+
true
119110
)
120111
})
121112
})

0 commit comments

Comments
 (0)