From b1fa8cca19896a8d71f27ab1a06bbee1522a6899 Mon Sep 17 00:00:00 2001 From: Adam Azarchs Date: Wed, 18 Jan 2023 12:14:00 -0800 Subject: [PATCH] Generalize test mock. --- __tests__/main.test.ts | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index d211cf0fb..ed1d12154 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -50,7 +50,8 @@ 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 @@ -58,10 +59,7 @@ describe('run', () => { .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'); @@ -86,7 +84,8 @@ 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 @@ -94,10 +93,7 @@ describe('run', () => { .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');