Skip to content

Commit

Permalink
Generalize test mock.
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-azarchs committed Jan 18, 2023
1 parent e273ca4 commit b1fa8cc
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,16 @@ describe('run', () => {
it('(with sync-labels: true) it deletes preexisting PR labels that no longer match the glob pattern', async () => {
let mockInput = {
'repo-token': 'foo',
'configuration-path': 'bar'
'configuration-path': 'bar',
'sync-labels': true
};

jest
.spyOn(core, 'getInput')
.mockImplementation((name: string, ...opts) => mockInput[name]);
jest
.spyOn(core, 'getBooleanInput')
.mockImplementation((name: string, opts) => {
if (name !== 'sync-labels') throw new Error(`invalid input ${name}`);
return true;
});
.mockImplementation((name: string, ...opts) => mockInput[name]);

usingLabelerConfigYaml('only_pdfs.yml');
mockGitHubResponseChangedFiles('foo.txt');
Expand All @@ -86,18 +84,16 @@ describe('run', () => {
it('(with sync-labels: false) it issues no delete calls even when there are preexisting PR labels that no longer match the glob pattern', async () => {
let mockInput = {
'repo-token': 'foo',
'configuration-path': 'bar'
'configuration-path': 'bar',
'sync-labels': false
};

jest
.spyOn(core, 'getInput')
.mockImplementation((name: string, ...opts) => mockInput[name]);
jest
.spyOn(core, 'getBooleanInput')
.mockImplementation((name: string, opts) => {
if (name !== 'sync-labels') throw new Error(`invalid input ${name}`);
return false;
});
.mockImplementation((name: string, ...opts) => mockInput[name]);

usingLabelerConfigYaml('only_pdfs.yml');
mockGitHubResponseChangedFiles('foo.txt');
Expand Down

0 comments on commit b1fa8cc

Please sign in to comment.