Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Commit

Permalink
fix: tests with new token changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ayuhito committed Aug 9, 2021
1 parent cd8ef4b commit f0b7a0a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"scripts": {
"postpack": "rimraf oclif.manifest.json",
"posttest": "eslint . --ext .ts --config .eslintrc",
"prepack": "yarn test && rimraf lib && tsc -b && oclif-dev manifest && oclif-dev readme ",
"prepack": "rimraf lib && tsc -b && oclif-dev manifest && oclif-dev readme ",
"command": "./bin/run",
"version": "oclif-dev readme && git add README.md",
"test": "jest"
Expand Down
13 changes: 7 additions & 6 deletions src/publish/npm-publish.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { createBumpObject } from "../bump/bump";
import { exampleConfig3 } from "../utils/helpers/test-configs";
import { npmPublish } from "./npm-publish";

import type { Response } from "node-fetch";
import type { BumpObject } from "../bump/bump";

jest.mock("dotenv");
Expand All @@ -25,7 +26,7 @@ describe("NPM publish function", () => {
results = [];
process.env = { ...OLD_ENV };

mockedPublish.mockResolvedValue();
mockedPublish.mockResolvedValue({} as Response);

diff = await findDiff(exampleConfig3);
bumpObjects = await createBumpObject(diff, "patch");
Expand All @@ -51,21 +52,21 @@ describe("NPM publish function", () => {
});

test("Success", async () => {
process.env.NPM_AUTH_TOKEN = "test";
process.env.NPM_TOKEN = "test";

await expect(npmPublish(bumpObjects)).resolves.not.toThrow();
expect(results).toEqual([
chalk.bold.blue("Publishing test2..."),
chalk.bold.green("Successfully published test2!"),
chalk.bold.blue("Publishing test2@1.1.1..."),
chalk.bold.green("Successfully published test2@1.1.1!"),
]);
});

test("Failed publish", async () => {
process.env.NPM_AUTH_TOKEN = "test";
process.env.NPM_TOKEN = "test";
mockedPublish.mockRejectedValue("test-fail");

await expect(npmPublish(bumpObjects)).rejects.toThrow(
"Encountered an error publishing test2! test-fail"
"Encountered an error publishing test2!\ntest-fail"
);
});
});

0 comments on commit f0b7a0a

Please sign in to comment.