From 5a4eceb0a21c2f90fc2368f0cd374204d2deed33 Mon Sep 17 00:00:00 2001 From: Andrew Lisowski Date: Mon, 1 Feb 2021 12:04:32 -0800 Subject: [PATCH] add test --- .../released/__tests__/released-label.test.ts | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/plugins/released/__tests__/released-label.test.ts b/plugins/released/__tests__/released-label.test.ts index be69ec43d..6d2eb40c4 100644 --- a/plugins/released/__tests__/released-label.test.ts +++ b/plugins/released/__tests__/released-label.test.ts @@ -144,6 +144,32 @@ describe("release label plugin", () => { expect(comment).not.toHaveBeenCalled(); }); + test("should do nothing with PR that doesn't exist", async () => { + const releasedLabel = new ReleasedLabelPlugin(); + const autoHooks = makeHooks(); + releasedLabel.apply(({ + hooks: autoHooks, + labels: defaultLabels, + logger: dummyLog(), + options: {}, + comment, + git, + } as unknown) as Auto); + + getPr.mockRejectedValueOnce(new Error("PR dont exist")); + const commit = makeCommitFromMsg("normal commit with no bump (#123)"); + await autoHooks.afterRelease.promise({ + newVersion: "1.0.0", + lastRelease: "0.1.0", + commits: await log.normalizeCommits([commit]), + releaseNotes: "", + // @ts-ignore + response: mockResponse, + }); + + expect(comment).not.toHaveBeenCalled(); + }); + test("should do nothing without commits", async () => { const releasedLabel = new ReleasedLabelPlugin(); const autoHooks = makeHooks();