From 2c37dc0ba9c65b7362fe03f7a629538d77bfc10f Mon Sep 17 00:00:00 2001 From: Andrew Lisowski Date: Mon, 21 Sep 2020 10:33:27 -0700 Subject: [PATCH] update tests --- packages/cli/auto | 0 .../__tests__/all-contributors.test.ts | 12 ++-- plugins/cocoapods/__tests__/cocoapods.test.ts | 70 +++++++++++-------- plugins/crates/__tests__/crates.test.ts | 7 +- plugins/docker/__tests__/docker.test.ts | 7 +- .../__tests__/first-time-contributor.test.ts | 7 +- plugins/gem/__tests__/gem.test.ts | 7 +- plugins/git-tag/__tests__/git-tag.test.ts | 7 +- plugins/gradle/__tests__/gradle.test.ts | 7 +- plugins/maven/__tests__/maven.test.ts | 7 +- plugins/npm/__tests__/monorepo-log.test.ts | 12 ++-- plugins/npm/__tests__/npm-next.test.ts | 10 +-- plugins/npm/__tests__/npm.test.ts | 16 ++--- 13 files changed, 79 insertions(+), 90 deletions(-) delete mode 100755 packages/cli/auto diff --git a/packages/cli/auto b/packages/cli/auto deleted file mode 100755 index e69de29bb..000000000 diff --git a/plugins/all-contributors/__tests__/all-contributors.test.ts b/plugins/all-contributors/__tests__/all-contributors.test.ts index 019e5cb1b..91591bb55 100644 --- a/plugins/all-contributors/__tests__/all-contributors.test.ts +++ b/plugins/all-contributors/__tests__/all-contributors.test.ts @@ -30,14 +30,10 @@ addContributor.mockImplementation(addContributorMock); // @ts-ignore env.mockImplementation(envMock); // @ts-ignore -jest.mock("../../../packages/core/dist/utils/exec-promise", () => ({ - // @ts-ignore - default: (...args) => gitShow(...args), -})); -jest.mock("../../../packages/core/dist/utils/get-lerna-packages", () => ({ - // @ts-ignore - default: (...args) => getLernaPackages(...args), -})); +jest.mock("../../../packages/core/dist/utils/exec-promise", () => (...args) => + gitShow(...args) +); +jest.mock("../../../packages/core/dist/utils/get-lerna-packages", () => (...args: any[]) => getLernaPackages(...args)); jest.spyOn(process, "chdir").mockReturnValue(); const mockRead = (result: string) => diff --git a/plugins/cocoapods/__tests__/cocoapods.test.ts b/plugins/cocoapods/__tests__/cocoapods.test.ts index 556ec1a38..abd33b23c 100644 --- a/plugins/cocoapods/__tests__/cocoapods.test.ts +++ b/plugins/cocoapods/__tests__/cocoapods.test.ts @@ -47,10 +47,10 @@ const mockPodspec = (contents: string) => { }; let exec = jest.fn().mockResolvedValueOnce(""); -jest.mock("../../../packages/core/dist/utils/exec-promise", () => ({ - // @ts-ignore - default: (...args) => exec(...args), -})); +// @ts-ignore +jest.mock("../../../packages/core/dist/utils/exec-promise", () => (...args) => + exec(...args) +); describe("Cocoapods Plugin", () => { let hooks: Auto.IAutoHooks; @@ -210,7 +210,7 @@ describe("Cocoapods Plugin", () => { test("should push with different pod command if in options", async () => { mockPodspec(specWithVersion("0.0.1")); - const plugin = new CocoapodsPlugin({...options, podCommand: 'notpod'}); + const plugin = new CocoapodsPlugin({ ...options, podCommand: "notpod" }); const hook = makeHooks(); plugin.apply({ hooks: hook, @@ -221,13 +221,20 @@ describe("Cocoapods Plugin", () => { await hook.publish.promise(Auto.SEMVER.patch); expect(exec).toBeCalledTimes(2); - expect(exec).lastCalledWith("notpod", ["trunk", "push", "./Test.podspec"]); + expect(exec).lastCalledWith("notpod", [ + "trunk", + "push", + "./Test.podspec", + ]); }); test("should push with different pod command with spaces if in options", async () => { mockPodspec(specWithVersion("0.0.1")); - const plugin = new CocoapodsPlugin({...options, podCommand: 'bundle exec pod'}); + const plugin = new CocoapodsPlugin({ + ...options, + podCommand: "bundle exec pod", + }); const hook = makeHooks(); plugin.apply({ hooks: hook, @@ -238,13 +245,22 @@ describe("Cocoapods Plugin", () => { await hook.publish.promise(Auto.SEMVER.patch); expect(exec).toBeCalledTimes(2); - expect(exec).lastCalledWith("bundle", ["exec", "pod", "trunk", "push", "./Test.podspec"]); + expect(exec).lastCalledWith("bundle", [ + "exec", + "pod", + "trunk", + "push", + "./Test.podspec", + ]); }); test("should push to trunk if no specsRepo in options with flags", async () => { mockPodspec(specWithVersion("0.0.1")); - const plugin = new CocoapodsPlugin({ ...options, flags: ["--sources", "someOtherSpecsRepo"]}); + const plugin = new CocoapodsPlugin({ + ...options, + flags: ["--sources", "someOtherSpecsRepo"], + }); const hook = makeHooks(); plugin.apply({ hooks: hook, @@ -255,7 +271,13 @@ describe("Cocoapods Plugin", () => { await hook.publish.promise(Auto.SEMVER.patch); expect(exec).toBeCalledTimes(2); - expect(exec).lastCalledWith("pod", ["trunk", "push", "--sources", "someOtherSpecsRepo", "./Test.podspec"]); + expect(exec).lastCalledWith("pod", [ + "trunk", + "push", + "--sources", + "someOtherSpecsRepo", + "./Test.podspec", + ]); }); test("should push to specs repo if specsRepo in options", async () => { @@ -275,10 +297,7 @@ describe("Cocoapods Plugin", () => { await hook.publish.promise(Auto.SEMVER.patch); expect(exec).toBeCalledTimes(5); - expect(exec).toHaveBeenNthCalledWith(2, "pod", [ - "repo", - "list" - ]); + expect(exec).toHaveBeenNthCalledWith(2, "pod", ["repo", "list"]); expect(exec).toHaveBeenNthCalledWith(3, "pod", [ "repo", "add", @@ -304,10 +323,7 @@ describe("Cocoapods Plugin", () => { const plugin = new CocoapodsPlugin({ ...options, specsRepo: "someSpecsRepo", - flags: [ - "--sources", - "someOtherSpecsRepo" - ] + flags: ["--sources", "someOtherSpecsRepo"], }); const hook = makeHooks(); plugin.apply({ @@ -319,10 +335,7 @@ describe("Cocoapods Plugin", () => { await hook.publish.promise(Auto.SEMVER.patch); expect(exec).toBeCalledTimes(5); - expect(exec).toHaveBeenNthCalledWith(2, "pod", [ - "repo", - "list" - ]); + expect(exec).toHaveBeenNthCalledWith(2, "pod", ["repo", "list"]); expect(exec).toHaveBeenNthCalledWith(3, "pod", [ "repo", "add", @@ -347,7 +360,7 @@ describe("Cocoapods Plugin", () => { mockPodspec(specWithVersion("0.0.1")); exec = jest.fn().mockImplementation((...args) => { - if (args[1]?.[1] === 'list') { + if (args[1]?.[1] === "list") { return ` autoPublishRepo - Type: git (master) @@ -363,9 +376,9 @@ trunk - Type: CDN - URL: https://cdn.cocoapods.org/ - Path: /Users/someUser/.cocoapods/repos/trunk - ` + `; } - }) + }); const plugin = new CocoapodsPlugin({ ...options, @@ -381,14 +394,11 @@ trunk await hook.publish.promise(Auto.SEMVER.patch); expect(exec).toBeCalledTimes(6); - expect(exec).toHaveBeenNthCalledWith(2, "pod", [ - "repo", - "list" - ]); + expect(exec).toHaveBeenNthCalledWith(2, "pod", ["repo", "list"]); expect(exec).toHaveBeenNthCalledWith(3, "pod", [ "repo", "remove", - "autoPublishRepo" + "autoPublishRepo", ]); expect(exec).toHaveBeenNthCalledWith(4, "pod", [ "repo", diff --git a/plugins/crates/__tests__/crates.test.ts b/plugins/crates/__tests__/crates.test.ts index ab5beb3ee..e65fa3907 100644 --- a/plugins/crates/__tests__/crates.test.ts +++ b/plugins/crates/__tests__/crates.test.ts @@ -41,10 +41,9 @@ const writeFile = jest.fn(); const writeFileSync = jest.fn(); const readResult = "{}"; -jest.mock('../../../packages/core/dist/utils/exec-promise', () => ({ - // @ts-ignore - default: (...args) => exec(...args) -})) +jest.mock("../../../packages/core/dist/utils/exec-promise", () => (...args: any[]) => + exec(...args) +); // @ts-ignore jest.mock("env-ci", () => () => ({ isCi: false })); jest.mock("fs", () => ({ diff --git a/plugins/docker/__tests__/docker.test.ts b/plugins/docker/__tests__/docker.test.ts index 19b360f2b..e0a574d33 100644 --- a/plugins/docker/__tests__/docker.test.ts +++ b/plugins/docker/__tests__/docker.test.ts @@ -8,10 +8,9 @@ const exec = jest.fn(); jest.mock("../../../packages/core/dist/utils/get-current-branch", () => ({ getCurrentBranch: () => "next", })); -jest.mock("../../../packages/core/dist/utils/exec-promise", () => ({ - // @ts-ignore - default: (...args) => exec(...args), -})); +jest.mock("../../../packages/core/dist/utils/exec-promise", () => (...args: any[]) => + exec(...args) +); const registry = "registry.io/app"; diff --git a/plugins/first-time-contributor/__tests__/first-time-contributor.test.ts b/plugins/first-time-contributor/__tests__/first-time-contributor.test.ts index 09c4a4e5d..1515be9c0 100644 --- a/plugins/first-time-contributor/__tests__/first-time-contributor.test.ts +++ b/plugins/first-time-contributor/__tests__/first-time-contributor.test.ts @@ -13,10 +13,9 @@ const graphql = jest.fn(); const exec = jest.fn(); exec.mockReturnValue(""); // @ts-ignore -jest.mock("../../../packages/core/dist/utils/exec-promise", () => ({ - // @ts-ignore - default: (...args) => exec(...args), -})); +jest.mock("../../../packages/core/dist/utils/exec-promise", () => (...args: any[]) => + exec(...args) +); const setup = ( contributors: Array< diff --git a/plugins/gem/__tests__/gem.test.ts b/plugins/gem/__tests__/gem.test.ts index 018ef049b..a73e7653f 100644 --- a/plugins/gem/__tests__/gem.test.ts +++ b/plugins/gem/__tests__/gem.test.ts @@ -19,10 +19,9 @@ const execSpy = jest.fn(); execSpy.mockReturnValue(""); // @ts-ignore -jest.mock("../../../packages/core/dist/utils/exec-promise", () => ({ - // @ts-ignore - default: (...args) => execSpy(...args), -})); +jest.mock("../../../packages/core/dist/utils/exec-promise", () => (...args: any[]) => + execSpy(...args) +); const globSpy = jest.fn(); jest.mock("fast-glob"); diff --git a/plugins/git-tag/__tests__/git-tag.test.ts b/plugins/git-tag/__tests__/git-tag.test.ts index aee4ce240..37f0b6ad7 100644 --- a/plugins/git-tag/__tests__/git-tag.test.ts +++ b/plugins/git-tag/__tests__/git-tag.test.ts @@ -8,10 +8,9 @@ const exec = jest.fn(); jest.mock("../../../packages/core/dist/utils/get-current-branch", () => ({ getCurrentBranch: () => "next", })); -jest.mock("../../../packages/core/dist/utils/exec-promise", () => ({ - // @ts-ignore - default: (...args) => exec(...args), -})); +jest.mock("../../../packages/core/dist/utils/exec-promise", () => (...args: any[]) => + exec(...args) +); const setup = (mockGit?: any) => { const plugin = new GitTag(); diff --git a/plugins/gradle/__tests__/gradle.test.ts b/plugins/gradle/__tests__/gradle.test.ts index c811ca45a..b873e73d3 100644 --- a/plugins/gradle/__tests__/gradle.test.ts +++ b/plugins/gradle/__tests__/gradle.test.ts @@ -8,10 +8,9 @@ import GradleReleasePlugin, { const exec = jest.fn(); -jest.mock("../../../packages/core/dist/utils/exec-promise", () => ({ - // @ts-ignore - default: (...args) => exec(...args), -})); +jest.mock("../../../packages/core/dist/utils/exec-promise", () => (...args: any[]) => + exec(...args) +); describe("Gradle Plugin", () => { let hooks: Auto.IAutoHooks; diff --git a/plugins/maven/__tests__/maven.test.ts b/plugins/maven/__tests__/maven.test.ts index d9905a2de..7e2d992b2 100644 --- a/plugins/maven/__tests__/maven.test.ts +++ b/plugins/maven/__tests__/maven.test.ts @@ -46,10 +46,9 @@ const mockReadFile = (result: string) => // @ts-ignore execSync.mockImplementation(exec); -jest.mock("../../../packages/core/dist/utils/exec-promise", () => ({ - // @ts-ignore - default: (...args) => exec(...args), -})); +jest.mock("../../../packages/core/dist/utils/exec-promise", () => (...args: any[]) => + exec(...args) +); describe("maven", () => { let hooks: Auto.IAutoHooks; diff --git a/plugins/npm/__tests__/monorepo-log.test.ts b/plugins/npm/__tests__/monorepo-log.test.ts index f44d8592f..2018c7c2d 100644 --- a/plugins/npm/__tests__/monorepo-log.test.ts +++ b/plugins/npm/__tests__/monorepo-log.test.ts @@ -19,14 +19,10 @@ jest.mock("child_process"); // @ts-ignore execSync.mockImplementation(exec); -jest.mock("../../../packages/core/dist/utils/get-lerna-packages", () => ({ - // @ts-ignore - default: (...args) => getLernaPackages(...args), -})); -jest.mock("../../../packages/core/dist/utils/exec-promise", () => ({ - // @ts-ignore - default: (...args) => execPromise(...args), -})); +jest.mock("../../../packages/core/dist/utils/get-lerna-packages", () => (...args: any[]) => getLernaPackages(...args)); +jest.mock("../../../packages/core/dist/utils/exec-promise", () => (...args: any[]) => + execPromise(...args) +); jest.mock("fs", () => ({ // @ts-ignore existsSync: jest.fn().mockReturnValue(true), diff --git a/plugins/npm/__tests__/npm-next.test.ts b/plugins/npm/__tests__/npm-next.test.ts index 49b1c8055..e1541a630 100644 --- a/plugins/npm/__tests__/npm-next.test.ts +++ b/plugins/npm/__tests__/npm-next.test.ts @@ -22,17 +22,11 @@ execPromise.mockResolvedValue(""); let readResult = "{}"; readFileSync.mockReturnValue("{}"); -jest.mock("../../../packages/core/dist/utils/exec-promise", () => ({ - // @ts-ignore - default: (...args) => execPromise(...args), -})); +jest.mock("../../../packages/core/dist/utils/exec-promise", () => (...args: any[]) => execPromise(...args)); jest.mock("../../../packages/core/dist/utils/get-current-branch", () => ({ getCurrentBranch: () => "next", })); -jest.mock("../../../packages/core/dist/utils/get-lerna-packages", () => ({ - // @ts-ignore - default: (...args) => getLernaPackages(...args), -})); +jest.mock("../../../packages/core/dist/utils/get-lerna-packages", () => (...args: any[]) => getLernaPackages(...args)); jest.mock("env-ci", () => () => ({ isCi: false })); jest.mock("get-monorepo-packages", () => () => monorepoPackages()); jest.mock("fs", () => ({ diff --git a/plugins/npm/__tests__/npm.test.ts b/plugins/npm/__tests__/npm.test.ts index 48770c147..df70c2892 100644 --- a/plugins/npm/__tests__/npm.test.ts +++ b/plugins/npm/__tests__/npm.test.ts @@ -28,17 +28,17 @@ let readResult = "{}"; readFileSync.mockReturnValue("{}"); jest.mock("../src/set-npm-token.ts"); -jest.mock("../../../packages/core/dist/utils/exec-promise", () => ({ - // @ts-ignore - default: (...args) => execPromise(...args), -})); +jest.mock( + "../../../packages/core/dist/utils/exec-promise", + () => (...args: any[]) => execPromise(...args) +); jest.mock("../../../packages/core/dist/utils/get-current-branch", () => ({ getCurrentBranch: () => "master", })); -jest.mock("../../../packages/core/dist/utils/get-lerna-packages", () => ({ - // @ts-ignore - default: (...args) => getLernaPackages(...args), -})); +jest.mock( + "../../../packages/core/dist/utils/get-lerna-packages", + () => (...args: any[]) => getLernaPackages(...args) +); jest.mock("env-ci", () => () => ({ isCi: false })); jest.mock("get-monorepo-packages", () => () => monorepoPackages()); jest.mock("fs", () => ({