Run prettier

This commit is contained in:
Josh Dales
2023-01-11 17:09:44 -05:00
parent 7f8d8e472d
commit c54c5a2057
2 changed files with 27 additions and 27 deletions

View File

@@ -15,8 +15,8 @@ const paginateMock = jest.spyOn(gh, 'paginate');
const getPullMock = jest.spyOn(gh.rest.pulls, 'get'); const getPullMock = jest.spyOn(gh.rest.pulls, 'get');
const yamlFixtures = { const yamlFixtures = {
'branches.yml': fs.readFileSync("__tests__/fixtures/branches.yml"), 'branches.yml': fs.readFileSync('__tests__/fixtures/branches.yml'),
'only_pdfs.yml': fs.readFileSync("__tests__/fixtures/only_pdfs.yml"), 'only_pdfs.yml': fs.readFileSync('__tests__/fixtures/only_pdfs.yml')
}; };
afterAll(() => jest.restoreAllMocks()); afterAll(() => jest.restoreAllMocks());
@@ -104,61 +104,61 @@ describe('run', () => {
expect(removeLabelMock).toHaveBeenCalledTimes(0); expect(removeLabelMock).toHaveBeenCalledTimes(0);
}); });
it("adds labels based on the branch names that match the glob pattern", async () => { it('adds labels based on the branch names that match the glob pattern', async () => {
github.context.payload.pull_request!.head = { ref: "test/testing-time" }; github.context.payload.pull_request!.head = {ref: 'test/testing-time'};
usingLabelerConfigYaml("branches.yml"); usingLabelerConfigYaml('branches.yml');
await run(); await run();
expect(addLabelsMock).toHaveBeenCalledTimes(1); expect(addLabelsMock).toHaveBeenCalledTimes(1);
expect(addLabelsMock).toHaveBeenCalledWith({ expect(addLabelsMock).toHaveBeenCalledWith({
owner: "monalisa", owner: 'monalisa',
repo: "helloworld", repo: 'helloworld',
issue_number: 123, issue_number: 123,
labels: ["test-branch"], labels: ['test-branch']
}); });
}); });
it("adds multiple labels based on branch names that match different glob patterns", async () => { it('adds multiple labels based on branch names that match different glob patterns', async () => {
github.context.payload.pull_request!.head = { github.context.payload.pull_request!.head = {
ref: "test/feature/123", ref: 'test/feature/123'
}; };
usingLabelerConfigYaml("branches.yml"); usingLabelerConfigYaml('branches.yml');
await run(); await run();
expect(addLabelsMock).toHaveBeenCalledTimes(1); expect(addLabelsMock).toHaveBeenCalledTimes(1);
expect(addLabelsMock).toHaveBeenCalledWith({ expect(addLabelsMock).toHaveBeenCalledWith({
owner: "monalisa", owner: 'monalisa',
repo: "helloworld", repo: 'helloworld',
issue_number: 123, issue_number: 123,
labels: ["test-branch", "feature-branch"], labels: ['test-branch', 'feature-branch']
}); });
}); });
it("it can support multiple branches by batching", async () => { it('it can support multiple branches by batching', async () => {
github.context.payload.pull_request!.head = { ref: "fix/123" }; github.context.payload.pull_request!.head = {ref: 'fix/123'};
usingLabelerConfigYaml("branches.yml"); usingLabelerConfigYaml('branches.yml');
await run(); await run();
expect(addLabelsMock).toHaveBeenCalledTimes(1); expect(addLabelsMock).toHaveBeenCalledTimes(1);
expect(addLabelsMock).toHaveBeenCalledWith({ expect(addLabelsMock).toHaveBeenCalledWith({
owner: "monalisa", owner: 'monalisa',
repo: "helloworld", repo: 'helloworld',
issue_number: 123, issue_number: 123,
labels: ["bug-branch"], labels: ['bug-branch']
}); });
}); });
it("it can support multiple branches by providing an array", async () => { it('it can support multiple branches by providing an array', async () => {
github.context.payload.pull_request!.head = { ref: "array/123" }; github.context.payload.pull_request!.head = {ref: 'array/123'};
usingLabelerConfigYaml("branches.yml"); usingLabelerConfigYaml('branches.yml');
await run(); await run();
expect(addLabelsMock).toHaveBeenCalledTimes(1); expect(addLabelsMock).toHaveBeenCalledTimes(1);
expect(addLabelsMock).toHaveBeenCalledWith({ expect(addLabelsMock).toHaveBeenCalledWith({
owner: "monalisa", owner: 'monalisa',
repo: "helloworld", repo: 'helloworld',
issue_number: 123, issue_number: 123,
labels: ["array-branch"], labels: ['array-branch']
}); });
}); });
}); });

View File

@@ -243,7 +243,7 @@ function checkBranch(glob: string | string[]): boolean {
core.debug(` checking "branch" pattern against ${branchName}`); core.debug(` checking "branch" pattern against ${branchName}`);
if (Array.isArray(glob)) { if (Array.isArray(glob)) {
const matchers = glob.map((g) => new Minimatch(g)); const matchers = glob.map(g => new Minimatch(g));
for (const matcher of matchers) { for (const matcher of matchers) {
if (matchBranchPattern(matcher, branchName)) { if (matchBranchPattern(matcher, branchName)) {
core.debug(` "branch" patterns matched against ${branchName}`); core.debug(` "branch" patterns matched against ${branchName}`);