Skip to content

Commit

Permalink
Squash actions#113
Browse files Browse the repository at this point in the history
  • Loading branch information
jjerphan committed Nov 15, 2022
2 parents 5c75392 + 3118216 commit 1ef5c18
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
28 changes: 26 additions & 2 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe("run", () => {
let mockInput = {
"repo-token": "foo",
"configuration-path": "bar",
"sync-labels": true,
"sync-labels": "true",
};

jest
Expand Down Expand Up @@ -82,7 +82,31 @@ describe("run", () => {
let mockInput = {
"repo-token": "foo",
"configuration-path": "bar",
"sync-labels": false,
"sync-labels": "false",
};

jest
.spyOn(core, "getInput")
.mockImplementation((name: string, ...opts) => mockInput[name]);

usingLabelerConfigYaml("only_pdfs.yml");
mockGitHubResponseChangedFiles("foo.txt");
getPullMock.mockResolvedValue(<any>{
data: {
labels: [{ name: "touched-a-pdf-file" }],
},
});

await run();

expect(addLabelsMock).toHaveBeenCalledTimes(0);
expect(removeLabelMock).toHaveBeenCalledTimes(0);
});

it("(with sync-labels not specified) it behaves like sync-labels: false", async () => {
let mockInput = {
"repo-token": "foo",
"configuration-path": "bar",
};

jest
Expand Down
3 changes: 2 additions & 1 deletion src/labeler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export async function run() {
try {
const token = core.getInput("repo-token", { required: true });
const configPath = core.getInput("configuration-path", { required: true });
const syncLabels = !!core.getInput("sync-labels", { required: false });
const syncLabels =
core.getInput("sync-labels", { required: false }) === "true";

const prNumber = getPrNumber();
if (!prNumber) {
Expand Down

0 comments on commit 1ef5c18

Please sign in to comment.