From a01b9aebb22860e7c07670a31c928d05604ca8cf Mon Sep 17 00:00:00 2001 From: Josh Dales Date: Sat, 7 Aug 2021 15:20:20 -0400 Subject: [PATCH] Add another test to make sure that partial branch naming works --- __mocks__/@actions/github.ts | 1 - __tests__/main.test.ts | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/__mocks__/@actions/github.ts b/__mocks__/@actions/github.ts index 12afe422..d423a29d 100644 --- a/__mocks__/@actions/github.ts +++ b/__mocks__/@actions/github.ts @@ -8,7 +8,6 @@ export const context = { owner: "monalisa", repo: "helloworld", }, - ref: "test/testing-time", }; const mockApi = { diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index 3e6529ab..fb93a02f 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -105,6 +105,7 @@ describe("run", () => { }); it("adds labels based on the branch names that match the glob pattern", async () => { + github.context.ref = "test/testing-time"; usingLabelerConfigYaml("branches.yml"); await run(); @@ -116,6 +117,20 @@ describe("run", () => { labels: ["test-branch"], }); }); + + it("adds labels based on branch names that match the glob pattern", async () => { + github.context.ref = "my/feature/that-i-like"; + usingLabelerConfigYaml("branches.yml"); + await run(); + + expect(addLabelsMock).toHaveBeenCalledTimes(1); + expect(addLabelsMock).toHaveBeenCalledWith({ + owner: "monalisa", + repo: "helloworld", + issue_number: 123, + labels: ["feature-branch"], + }); + }); }); function usingLabelerConfigYaml(fixtureName: keyof typeof yamlFixtures): void {