mirror of
https://github.com/actions/labeler.git
synced 2025-12-11 03:58:05 +00:00
Add a new fixture and test for the branch checking
This commit is contained in:
@@ -8,6 +8,7 @@ export const context = {
|
||||
owner: "monalisa",
|
||||
repo: "helloworld",
|
||||
},
|
||||
ref: "test/testing-time",
|
||||
};
|
||||
|
||||
const mockApi = {
|
||||
|
||||
5
__tests__/fixtures/branches.yml
Normal file
5
__tests__/fixtures/branches.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
test-branch:
|
||||
- branch: "test/*"
|
||||
|
||||
feature-branch:
|
||||
- branch: "*/feature/*"
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user