Add a new fixture and test for the branch checking

This commit is contained in:
Josh Dales
2021-08-07 15:12:02 -04:00
parent 6c50d09410
commit ee0e0eb513
3 changed files with 20 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ export const context = {
owner: "monalisa",
repo: "helloworld",
},
ref: "test/testing-time",
};
const mockApi = {

View File

@@ -0,0 +1,5 @@
test-branch:
- branch: "test/*"
feature-branch:
- branch: "*/feature/*"

View File

@@ -15,6 +15,7 @@ const paginateMock = jest.spyOn(gh, "paginate");
const getPullMock = jest.spyOn(gh.rest.pulls, "get");
const yamlFixtures = {
"branches.yml": fs.readFileSync("__tests__/fixtures/branches.yml"),
"only_pdfs.yml": fs.readFileSync("__tests__/fixtures/only_pdfs.yml"),
};
@@ -102,6 +103,19 @@ describe("run", () => {
expect(addLabelsMock).toHaveBeenCalledTimes(0);
expect(removeLabelMock).toHaveBeenCalledTimes(0);
});
it("adds labels based on the branch names that match the glob pattern", async () => {
usingLabelerConfigYaml("branches.yml");
await run();
expect(addLabelsMock).toHaveBeenCalledTimes(1);
expect(addLabelsMock).toHaveBeenCalledWith({
owner: "monalisa",
repo: "helloworld",
issue_number: 123,
labels: ["test-branch"],
});
});
});
function usingLabelerConfigYaml(fixtureName: keyof typeof yamlFixtures): void {