From 7e52e0cdc15164c4b7bbfef42b4ac90ce6ecfefb Mon Sep 17 00:00:00 2001 From: Ross Brodbeck Date: Thu, 16 Apr 2020 14:15:34 -0400 Subject: [PATCH] Add a test to days = -1 --- __tests__/main.test.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index e948c4fe..56ec6f21 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -178,3 +178,25 @@ test('exempt pr labels will not be marked stale', async () => { expect(processor.staleIssues.length).toEqual(2); // PR should get processed even though it has an exempt **issue** label }); + +test('stale issues should not be closed if days is set to -1', async () => { + const TestIssueList: Issue[] = [ + generateIssue(1, 'My first issue', '2020-01-01T17:00:00Z', false, [ + 'Stale' + ]), + generateIssue(2, 'My first PR', '2020-01-01T17:00:00Z', true, ['Stale']), + generateIssue(3, 'Another issue', '2020-01-01T17:00:00Z', false, ['Stale']) + ]; + + let opts = DefaultProcessorOptions; + opts.daysBeforeClose = -1; + + const processor = new IssueProcessor(DefaultProcessorOptions, async p => + p == 1 ? TestIssueList : [] + ); + + // process our fake issue list + await processor.processIssues(1); + + expect(processor.closedIssues.length).toEqual(0); +});