From ab49f7a2bdd036a155b0ccc9468d728f71dda911 Mon Sep 17 00:00:00 2001 From: Josh Dales <30500472+joshdales@users.noreply.github.com> Date: Wed, 29 Sep 2021 10:32:05 -0400 Subject: [PATCH] Add tests for array branh labelling --- __tests__/fixtures/branches.yml | 3 +++ __tests__/main.test.ts | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/__tests__/fixtures/branches.yml b/__tests__/fixtures/branches.yml index b72c67f2..30bbbb39 100644 --- a/__tests__/fixtures/branches.yml +++ b/__tests__/fixtures/branches.yml @@ -6,3 +6,6 @@ feature-branch: bug-branch: - branch: "{bug,fix}/*" + +array-branch: + - branch: ["array/*", "*/array/*"] diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index 85e85f4c..82b302ed 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -147,6 +147,20 @@ describe("run", () => { labels: ["bug-branch"], }); }); + + it("it can support multiple branches by providing an array", async () => { + github.context.payload.pull_request!.head = { ref: "array/123" }; + usingLabelerConfigYaml("branches.yml"); + await run(); + + expect(addLabelsMock).toHaveBeenCalledTimes(1); + expect(addLabelsMock).toHaveBeenCalledWith({ + owner: "monalisa", + repo: "helloworld", + issue_number: 123, + labels: ["array-branch"], + }); + }); }); function usingLabelerConfigYaml(fixtureName: keyof typeof yamlFixtures): void {