2020-04-17 01:57:59 +08:00
import * as github from '@actions/github' ;
2021-01-19 18:54:16 +08:00
import { Issue } from '../src/classes/issue' ;
import { IssueProcessor , IssueProcessorOptions } from '../src/IssueProcessor' ;
2021-01-18 09:22:36 +08:00
import { IsoDateString } from '../src/types/iso-date-string' ;
2020-04-17 01:57:59 +08:00
function generateIssue (
2021-01-19 18:54:16 +08:00
options : IssueProcessorOptions ,
2020-04-17 01:57:59 +08:00
id : number ,
title : string ,
2021-01-18 09:22:36 +08:00
updatedAt : IsoDateString ,
createdAt : IsoDateString = updatedAt ,
2020-04-17 01:57:59 +08:00
isPullRequest : boolean = false ,
2020-04-27 19:53:58 +08:00
labels : string [ ] = [ ] ,
isClosed : boolean = false ,
2021-01-19 18:54:16 +08:00
isLocked : boolean = false ,
milestone = ''
2020-04-17 01:57:59 +08:00
) : Issue {
2021-01-19 18:54:16 +08:00
return new Issue ( options , {
2020-04-17 01:57:59 +08:00
number : id ,
labels : labels.map ( l = > {
return { name : l } ;
} ) ,
title : title ,
2021-01-18 09:22:36 +08:00
created_at : createdAt ,
2020-04-17 01:57:59 +08:00
updated_at : updatedAt ,
2020-04-27 19:53:58 +08:00
pull_request : isPullRequest ? { } : null ,
state : isClosed ? 'closed' : 'open' ,
2021-01-19 18:54:16 +08:00
locked : isLocked ,
milestone : {
title : milestone
}
} ) ;
2020-04-17 01:57:59 +08:00
}
2020-07-14 04:18:51 +08:00
const DefaultProcessorOptions : IssueProcessorOptions = Object . freeze ( {
2020-04-17 01:57:59 +08:00
repoToken : 'none' ,
staleIssueMessage : 'This issue is stale' ,
stalePrMessage : 'This PR is stale' ,
2020-07-14 01:05:59 +08:00
closeIssueMessage : 'This issue is being closed' ,
closePrMessage : 'This PR is being closed' ,
2020-04-17 01:57:59 +08:00
daysBeforeStale : 1 ,
2021-01-16 21:28:29 +08:00
daysBeforeIssueStale : NaN ,
daysBeforePrStale : NaN ,
2020-05-11 23:15:05 +08:00
daysBeforeClose : 30 ,
2021-01-16 21:28:29 +08:00
daysBeforeIssueClose : NaN ,
daysBeforePrClose : NaN ,
2020-04-17 01:57:59 +08:00
staleIssueLabel : 'Stale' ,
2020-09-09 03:32:42 +08:00
closeIssueLabel : '' ,
2020-04-17 01:57:59 +08:00
exemptIssueLabels : '' ,
stalePrLabel : 'Stale' ,
2020-09-09 03:32:42 +08:00
closePrLabel : '' ,
2020-04-17 01:57:59 +08:00
exemptPrLabels : '' ,
onlyLabels : '' ,
operationsPerRun : 100 ,
2020-05-11 22:46:03 +08:00
debugOnly : true ,
2020-06-24 01:55:24 +08:00
removeStaleWhenUpdated : false ,
2020-07-24 20:08:48 +08:00
ascending : false ,
skipStaleIssueMessage : false ,
2021-01-15 19:49:38 +08:00
skipStalePrMessage : false ,
2021-01-18 09:22:36 +08:00
deleteBranch : false ,
2021-01-19 18:54:16 +08:00
startDate : '' ,
exemptMilestones : '' ,
exemptIssueMilestones : '' ,
exemptPrMilestones : ''
2020-07-14 04:18:51 +08:00
} ) ;
2020-04-17 01:57:59 +08:00
test ( 'empty issue list results in 1 operation' , async ( ) = > {
2020-05-11 22:46:03 +08:00
const processor = new IssueProcessor (
DefaultProcessorOptions ,
2021-01-15 20:20:32 +08:00
async ( ) = > 'abot' ,
2020-05-11 22:46:03 +08:00
async ( ) = > [ ] ,
async ( num , dt ) = > [ ] ,
async ( issue , label ) = > new Date ( ) . toDateString ( )
) ;
2020-04-17 01:57:59 +08:00
// process our fake issue list
const operationsLeft = await processor . processIssues ( 1 ) ;
// processing an empty issue list should result in 1 operation
expect ( operationsLeft ) . toEqual ( 99 ) ;
} ) ;
2020-05-29 21:32:20 +08:00
test ( 'processing an issue with no label will make it stale and close it, if it is old enough only if days-before-close is set to 0' , async ( ) = > {
2021-01-16 21:28:29 +08:00
const opts : IssueProcessorOptions = {
. . . DefaultProcessorOptions ,
daysBeforeClose : 0
} ;
2021-01-19 18:54:16 +08:00
const TestIssueList : Issue [ ] = [
generateIssue ( opts , 1 , 'An issue with no label' , '2020-01-01T17:00:00Z' )
] ;
2021-01-16 21:28:29 +08:00
const processor = new IssueProcessor (
opts ,
async ( ) = > 'abot' ,
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num , dt ) = > [ ] ,
async ( issue , label ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toEqual ( 1 ) ;
expect ( processor . closedIssues . length ) . toEqual ( 1 ) ;
} ) ;
2021-01-18 09:22:36 +08:00
test ( 'processing an issue with no label and a start date as ECMAScript epoch in seconds being before the issue creation date will not make it stale nor close it when it is old enough and days-before-close is set to 0' , async ( ) = > {
expect . assertions ( 2 ) ;
2021-01-19 18:54:16 +08:00
const january2000 = 946681200000 ;
const opts : IssueProcessorOptions = {
. . . DefaultProcessorOptions ,
daysBeforeClose : 0 ,
startDate : january2000.toString ( )
} ;
2021-01-18 09:22:36 +08:00
const TestIssueList : Issue [ ] = [
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2021-01-18 09:22:36 +08:00
1 ,
'An issue with no label' ,
'2020-01-01T17:00:00Z' ,
'2020-01-01T17:00:00Z'
)
] ;
const processor = new IssueProcessor (
opts ,
async ( ) = > 'abot' ,
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num , dt ) = > [ ] ,
async ( issue , label ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toStrictEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toStrictEqual ( 0 ) ;
} ) ;
test ( 'processing an issue with no label and a start date as ECMAScript epoch in seconds being after the issue creation date will not make it stale nor close it when it is old enough and days-before-close is set to 0' , async ( ) = > {
expect . assertions ( 2 ) ;
2021-01-19 18:54:16 +08:00
const january2021 = 1609455600000 ;
const opts : IssueProcessorOptions = {
. . . DefaultProcessorOptions ,
daysBeforeClose : 0 ,
startDate : january2021.toString ( )
} ;
2021-01-18 09:22:36 +08:00
const TestIssueList : Issue [ ] = [
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2021-01-18 09:22:36 +08:00
1 ,
'An issue with no label' ,
'2020-01-01T17:00:00Z' ,
'2020-01-01T17:00:00Z'
)
] ;
const processor = new IssueProcessor (
opts ,
async ( ) = > 'abot' ,
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num , dt ) = > [ ] ,
async ( issue , label ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toStrictEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toStrictEqual ( 0 ) ;
} ) ;
test ( 'processing an issue with no label and a start date as ECMAScript epoch in milliseconds being before the issue creation date will not make it stale nor close it when it is old enough and days-before-close is set to 0' , async ( ) = > {
expect . assertions ( 2 ) ;
2021-01-19 18:54:16 +08:00
const january2000 = 946681200000000 ;
const opts : IssueProcessorOptions = {
. . . DefaultProcessorOptions ,
daysBeforeClose : 0 ,
startDate : january2000.toString ( )
} ;
2021-01-18 09:22:36 +08:00
const TestIssueList : Issue [ ] = [
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2021-01-18 09:22:36 +08:00
1 ,
'An issue with no label' ,
'2020-01-01T17:00:00Z' ,
'2020-01-01T17:00:00Z'
)
] ;
const processor = new IssueProcessor (
opts ,
async ( ) = > 'abot' ,
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num , dt ) = > [ ] ,
async ( issue , label ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toStrictEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toStrictEqual ( 0 ) ;
} ) ;
test ( 'processing an issue with no label and a start date as ECMAScript epoch in milliseconds being after the issue creation date will not make it stale nor close it when it is old enough and days-before-close is set to 0' , async ( ) = > {
expect . assertions ( 2 ) ;
2021-01-19 18:54:16 +08:00
const january2021 = 1609455600000 ;
const opts : IssueProcessorOptions = {
. . . DefaultProcessorOptions ,
daysBeforeClose : 0 ,
startDate : january2021.toString ( )
} ;
2021-01-18 09:22:36 +08:00
const TestIssueList : Issue [ ] = [
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2021-01-18 09:22:36 +08:00
1 ,
'An issue with no label' ,
'2020-01-01T17:00:00Z' ,
'2020-01-01T17:00:00Z'
)
] ;
const processor = new IssueProcessor (
opts ,
async ( ) = > 'abot' ,
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num , dt ) = > [ ] ,
async ( issue , label ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toStrictEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toStrictEqual ( 0 ) ;
} ) ;
test ( 'processing an issue with no label and a start date as ISO 8601 being before the issue creation date will make it stale and close it when it is old enough and days-before-close is set to 0' , async ( ) = > {
expect . assertions ( 2 ) ;
2021-01-19 18:54:16 +08:00
const january2000 = '2000-01-01T00:00:00Z' ;
const opts : IssueProcessorOptions = {
. . . DefaultProcessorOptions ,
daysBeforeClose : 0 ,
startDate : january2000.toString ( )
} ;
2021-01-18 09:22:36 +08:00
const TestIssueList : Issue [ ] = [
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2021-01-18 09:22:36 +08:00
1 ,
'An issue with no label' ,
'2020-01-01T17:00:00Z' ,
'2020-01-01T17:00:00Z'
)
] ;
const processor = new IssueProcessor (
opts ,
async ( ) = > 'abot' ,
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num , dt ) = > [ ] ,
async ( issue , label ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toStrictEqual ( 1 ) ;
expect ( processor . closedIssues . length ) . toStrictEqual ( 1 ) ;
} ) ;
test ( 'processing an issue with no label and a start date as ISO 8601 being after the issue creation date will not make it stale nor close it when it is old enough and days-before-close is set to 0' , async ( ) = > {
expect . assertions ( 2 ) ;
2021-01-19 18:54:16 +08:00
const january2021 = '2021-01-01T00:00:00Z' ;
const opts : IssueProcessorOptions = {
. . . DefaultProcessorOptions ,
daysBeforeClose : 0 ,
startDate : january2021.toString ( )
} ;
2021-01-18 09:22:36 +08:00
const TestIssueList : Issue [ ] = [
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2021-01-18 09:22:36 +08:00
1 ,
'An issue with no label' ,
'2020-01-01T17:00:00Z' ,
'2020-01-01T17:00:00Z'
)
] ;
const processor = new IssueProcessor (
opts ,
async ( ) = > 'abot' ,
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num , dt ) = > [ ] ,
async ( issue , label ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toStrictEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toStrictEqual ( 0 ) ;
} ) ;
test ( 'processing an issue with no label and a start date as RFC 2822 being before the issue creation date will make it stale and close it when it is old enough and days-before-close is set to 0' , async ( ) = > {
expect . assertions ( 2 ) ;
2021-01-19 18:54:16 +08:00
const january2000 = 'January 1, 2000 00:00:00' ;
const opts : IssueProcessorOptions = {
. . . DefaultProcessorOptions ,
daysBeforeClose : 0 ,
startDate : january2000.toString ( )
} ;
2021-01-18 09:22:36 +08:00
const TestIssueList : Issue [ ] = [
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2021-01-18 09:22:36 +08:00
1 ,
'An issue with no label' ,
'2020-01-01T17:00:00Z' ,
'2020-01-01T17:00:00Z'
)
] ;
const processor = new IssueProcessor (
opts ,
async ( ) = > 'abot' ,
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num , dt ) = > [ ] ,
async ( issue , label ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toStrictEqual ( 1 ) ;
expect ( processor . closedIssues . length ) . toStrictEqual ( 1 ) ;
} ) ;
test ( 'processing an issue with no label and a start date as RFC 2822 being after the issue creation date will not make it stale nor close it when it is old enough and days-before-close is set to 0' , async ( ) = > {
expect . assertions ( 2 ) ;
2021-01-19 18:54:16 +08:00
const january2021 = 'January 1, 2021 00:00:00' ;
const opts : IssueProcessorOptions = {
. . . DefaultProcessorOptions ,
daysBeforeClose : 0 ,
startDate : january2021.toString ( )
} ;
2021-01-18 09:22:36 +08:00
const TestIssueList : Issue [ ] = [
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2021-01-18 09:22:36 +08:00
1 ,
'An issue with no label' ,
'2020-01-01T17:00:00Z' ,
'2020-01-01T17:00:00Z'
)
] ;
const processor = new IssueProcessor (
opts ,
async ( ) = > 'abot' ,
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num , dt ) = > [ ] ,
async ( issue , label ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toStrictEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toStrictEqual ( 0 ) ;
} ) ;
2021-01-16 21:28:29 +08:00
test ( 'processing an issue with no label will make it stale and close it, if it is old enough only if days-before-close is set to > 0 and days-before-issue-close is set to 0' , async ( ) = > {
const opts : IssueProcessorOptions = {
. . . DefaultProcessorOptions ,
daysBeforeClose : 1 ,
daysBeforeIssueClose : 0
} ;
2021-01-19 18:54:16 +08:00
const TestIssueList : Issue [ ] = [
generateIssue ( opts , 1 , 'An issue with no label' , '2020-01-01T17:00:00Z' )
] ;
2020-05-11 22:46:03 +08:00
const processor = new IssueProcessor (
2020-05-29 21:32:20 +08:00
opts ,
2021-01-15 20:20:32 +08:00
async ( ) = > 'abot' ,
2020-05-11 22:46:03 +08:00
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num , dt ) = > [ ] ,
async ( issue , label ) = > new Date ( ) . toDateString ( )
2020-04-17 01:57:59 +08:00
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
2020-05-11 23:15:05 +08:00
expect ( processor . staleIssues . length ) . toEqual ( 1 ) ;
expect ( processor . closedIssues . length ) . toEqual ( 1 ) ;
2021-01-15 19:49:38 +08:00
expect ( processor . deletedBranchIssues . length ) . toEqual ( 0 ) ;
2020-05-11 23:15:05 +08:00
} ) ;
2021-01-16 21:28:29 +08:00
test ( 'processing an issue with no label will make it stale and not close it, if it is old enough only if days-before-close is set to > 0 and days-before-issue-close is set to > 0' , async ( ) = > {
const opts : IssueProcessorOptions = {
. . . DefaultProcessorOptions ,
daysBeforeClose : 1 ,
daysBeforeIssueClose : 1
} ;
2021-01-19 18:54:16 +08:00
const TestIssueList : Issue [ ] = [
generateIssue ( opts , 1 , 'An issue with no label' , '2020-01-01T17:00:00Z' )
] ;
2021-01-16 21:28:29 +08:00
const processor = new IssueProcessor (
opts ,
async ( ) = > 'abot' ,
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num , dt ) = > [ ] ,
async ( issue , label ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toEqual ( 1 ) ;
expect ( processor . closedIssues . length ) . toEqual ( 0 ) ;
} ) ;
2020-05-29 21:32:20 +08:00
test ( 'processing an issue with no label will make it stale and not close it if days-before-close is set to > 0' , async ( ) = > {
2021-01-16 21:28:29 +08:00
const opts : IssueProcessorOptions = {
. . . DefaultProcessorOptions ,
daysBeforeClose : 15
} ;
2021-01-19 18:54:16 +08:00
const TestIssueList : Issue [ ] = [
generateIssue ( opts , 1 , 'An issue with no label' , '2020-01-01T17:00:00Z' )
] ;
2020-05-29 21:32:20 +08:00
const processor = new IssueProcessor (
2021-01-16 21:28:29 +08:00
opts ,
async ( ) = > 'abot' ,
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num , dt ) = > [ ] ,
async ( issue , label ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toEqual ( 1 ) ;
expect ( processor . closedIssues . length ) . toEqual ( 0 ) ;
} ) ;
test ( 'processing an issue with no label will make it stale and not close it if days-before-close is set to -1 and days-before-issue-close is set to > 0' , async ( ) = > {
const opts : IssueProcessorOptions = {
. . . DefaultProcessorOptions ,
daysBeforeClose : - 1 ,
daysBeforeIssueClose : 15
} ;
2021-01-19 18:54:16 +08:00
const TestIssueList : Issue [ ] = [
generateIssue ( opts , 1 , 'An issue with no label' , '2020-01-01T17:00:00Z' )
] ;
2021-01-16 21:28:29 +08:00
const processor = new IssueProcessor (
opts ,
2021-01-15 20:20:32 +08:00
async ( ) = > 'abot' ,
2020-05-29 21:32:20 +08:00
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num , dt ) = > [ ] ,
async ( issue , label ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toEqual ( 1 ) ;
expect ( processor . closedIssues . length ) . toEqual ( 0 ) ;
} ) ;
2020-07-14 04:20:45 +08:00
test ( 'processing an issue with no label will not make it stale if days-before-stale is set to -1' , async ( ) = > {
2021-01-16 21:28:29 +08:00
const opts : IssueProcessorOptions = {
2020-07-14 04:20:45 +08:00
. . . DefaultProcessorOptions ,
staleIssueMessage : '' ,
daysBeforeStale : - 1
} ;
2021-01-19 18:54:16 +08:00
const TestIssueList : Issue [ ] = [
generateIssue ( opts , 1 , 'An issue with no label' , '2020-01-01T17:00:00Z' )
] ;
2020-07-14 04:20:45 +08:00
const processor = new IssueProcessor (
opts ,
2021-01-15 20:20:32 +08:00
async ( ) = > 'abot' ,
2020-07-14 04:20:45 +08:00
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num , dt ) = > [ ] ,
async ( issue , label ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toEqual ( 0 ) ;
} ) ;
2021-01-16 21:28:29 +08:00
test ( 'processing an issue with no label will not make it stale if days-before-stale and days-before-issue-stale are set to -1' , async ( ) = > {
const opts : IssueProcessorOptions = {
. . . DefaultProcessorOptions ,
staleIssueMessage : '' ,
daysBeforeStale : - 1 ,
daysBeforeIssueStale : - 1
} ;
2021-01-19 18:54:16 +08:00
const TestIssueList : Issue [ ] = [
generateIssue ( opts , 1 , 'An issue with no label' , '2020-01-01T17:00:00Z' )
] ;
2021-01-16 21:28:29 +08:00
const processor = new IssueProcessor (
opts ,
async ( ) = > 'abot' ,
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num , dt ) = > [ ] ,
async ( issue , label ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toEqual ( 0 ) ;
} ) ;
2020-05-11 23:15:05 +08:00
test ( 'processing an issue with no label will make it stale but not close it' , async ( ) = > {
// issue should be from 2 days ago so it will be
// stale but not close-able, based on default settings
let issueDate = new Date ( ) ;
issueDate . setDate ( issueDate . getDate ( ) - 2 ) ;
const TestIssueList : Issue [ ] = [
2021-01-19 18:54:16 +08:00
generateIssue (
DefaultProcessorOptions ,
1 ,
'An issue with no label' ,
issueDate . toDateString ( )
)
2020-05-11 23:15:05 +08:00
] ;
const processor = new IssueProcessor (
DefaultProcessorOptions ,
2021-01-15 20:20:32 +08:00
async ( ) = > 'abot' ,
2020-05-11 23:15:05 +08:00
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num , dt ) = > [ ] ,
async ( issue , label ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
2020-04-17 01:57:59 +08:00
expect ( processor . staleIssues . length ) . toEqual ( 1 ) ;
expect ( processor . closedIssues . length ) . toEqual ( 0 ) ;
} ) ;
test ( 'processing a stale issue will close it' , async ( ) = > {
2021-01-19 18:54:16 +08:00
const opts : IssueProcessorOptions = {
. . . DefaultProcessorOptions ,
daysBeforeClose : 30
} ;
2020-04-17 01:57:59 +08:00
const TestIssueList : Issue [ ] = [
2020-05-11 22:46:03 +08:00
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2020-05-11 22:46:03 +08:00
1 ,
'A stale issue that should be closed' ,
'2020-01-01T17:00:00Z' ,
2021-01-18 09:22:36 +08:00
'2020-01-01T17:00:00Z' ,
2020-05-11 22:46:03 +08:00
false ,
[ 'Stale' ]
)
2020-04-17 01:57:59 +08:00
] ;
2020-05-11 22:46:03 +08:00
const processor = new IssueProcessor (
2021-01-16 21:28:29 +08:00
opts ,
2021-01-15 20:20:32 +08:00
async ( ) = > 'abot' ,
2020-05-11 22:46:03 +08:00
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num , dt ) = > [ ] ,
async ( issue , label ) = > new Date ( ) . toDateString ( )
2020-04-17 01:57:59 +08:00
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toEqual ( 1 ) ;
} ) ;
2021-01-15 19:51:24 +08:00
test ( 'processing a stale issue containing a space in the label will close it' , async ( ) = > {
2021-01-19 18:54:16 +08:00
const opts : IssueProcessorOptions = {
. . . DefaultProcessorOptions ,
staleIssueLabel : 'state: stale'
} ;
2021-01-15 19:51:24 +08:00
const TestIssueList : Issue [ ] = [
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2021-01-15 19:51:24 +08:00
1 ,
'A stale issue that should be closed' ,
'2020-01-01T17:00:00Z' ,
2021-01-18 09:22:36 +08:00
'2020-01-01T17:00:00Z' ,
2021-01-15 19:51:24 +08:00
false ,
[ 'state: stale' ]
)
] ;
const processor = new IssueProcessor (
opts ,
2021-01-15 20:35:41 +08:00
async ( ) = > 'abot' ,
2021-01-15 19:51:24 +08:00
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num , dt ) = > [ ] ,
async ( issue , label ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toEqual ( 1 ) ;
} ) ;
test ( 'processing a stale issue containing a slash in the label will close it' , async ( ) = > {
2021-01-19 18:54:16 +08:00
const opts : IssueProcessorOptions = {
. . . DefaultProcessorOptions ,
staleIssueLabel : 'lifecycle/stale'
} ;
2021-01-15 19:51:24 +08:00
const TestIssueList : Issue [ ] = [
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2021-01-15 19:51:24 +08:00
1 ,
'A stale issue that should be closed' ,
'2020-01-01T17:00:00Z' ,
2021-01-18 09:22:36 +08:00
'2020-01-01T17:00:00Z' ,
2021-01-15 19:51:24 +08:00
false ,
[ 'lifecycle/stale' ]
)
] ;
const processor = new IssueProcessor (
opts ,
2021-01-15 20:35:41 +08:00
async ( ) = > 'abot' ,
2021-01-15 19:51:24 +08:00
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num , dt ) = > [ ] ,
async ( issue , label ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toEqual ( 1 ) ;
} ) ;
2021-01-16 21:28:29 +08:00
test ( 'processing a stale issue will close it when days-before-issue-stale override days-before-stale' , async ( ) = > {
2021-01-19 18:54:16 +08:00
const opts : IssueProcessorOptions = {
. . . DefaultProcessorOptions ,
daysBeforeClose : 30 ,
daysBeforeIssueStale : 30
} ;
2021-01-16 21:28:29 +08:00
const TestIssueList : Issue [ ] = [
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2021-01-16 21:28:29 +08:00
1 ,
'A stale issue that should be closed' ,
'2020-01-01T17:00:00Z' ,
2021-01-18 09:22:36 +08:00
'2020-01-01T17:00:00Z' ,
2021-01-16 21:28:29 +08:00
false ,
[ 'Stale' ]
)
] ;
const processor = new IssueProcessor (
opts ,
async ( ) = > 'abot' ,
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num , dt ) = > [ ] ,
async ( issue , label ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toEqual ( 1 ) ;
} ) ;
2020-04-17 01:57:59 +08:00
test ( 'processing a stale PR will close it' , async ( ) = > {
2021-01-19 18:54:16 +08:00
const opts : IssueProcessorOptions = {
. . . DefaultProcessorOptions ,
daysBeforeClose : 30
} ;
2020-04-17 01:57:59 +08:00
const TestIssueList : Issue [ ] = [
2020-05-11 22:46:03 +08:00
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2020-05-11 22:46:03 +08:00
1 ,
'A stale PR that should be closed' ,
'2020-01-01T17:00:00Z' ,
2021-01-18 09:22:36 +08:00
'2020-01-01T17:00:00Z' ,
2020-05-11 22:46:03 +08:00
true ,
[ 'Stale' ]
)
2020-04-17 01:57:59 +08:00
] ;
2020-05-11 22:46:03 +08:00
const processor = new IssueProcessor (
2021-01-16 21:28:29 +08:00
opts ,
async ( ) = > 'abot' ,
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num , dt ) = > [ ] ,
async ( issue , label ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toEqual ( 1 ) ;
} ) ;
test ( 'processing a stale PR will close it when days-before-pr-stale override days-before-stale' , async ( ) = > {
2021-01-19 18:54:16 +08:00
const opts : IssueProcessorOptions = {
. . . DefaultProcessorOptions ,
daysBeforeClose : 30 ,
daysBeforePrClose : 30
} ;
2021-01-16 21:28:29 +08:00
const TestIssueList : Issue [ ] = [
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2021-01-16 21:28:29 +08:00
1 ,
'A stale PR that should be closed' ,
'2020-01-01T17:00:00Z' ,
2021-01-18 09:22:36 +08:00
'2020-01-01T17:00:00Z' ,
2021-01-16 21:28:29 +08:00
true ,
[ 'Stale' ]
)
] ;
const processor = new IssueProcessor (
opts ,
2021-01-15 20:20:32 +08:00
async ( ) = > 'abot' ,
2020-05-11 22:46:03 +08:00
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num , dt ) = > [ ] ,
async ( issue , label ) = > new Date ( ) . toDateString ( )
2020-07-14 04:20:45 +08:00
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toEqual ( 1 ) ;
} ) ;
test ( 'processing a stale issue will close it even if configured not to mark as stale' , async ( ) = > {
2021-01-19 18:54:16 +08:00
const opts = {
. . . DefaultProcessorOptions ,
daysBeforeStale : - 1 ,
staleIssueMessage : ''
} ;
2020-07-14 04:20:45 +08:00
const TestIssueList : Issue [ ] = [
2021-01-18 09:22:36 +08:00
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2021-01-18 09:22:36 +08:00
1 ,
'An issue with no label' ,
'2020-01-01T17:00:00Z' ,
'2020-01-01T17:00:00Z' ,
false ,
[ 'Stale' ]
)
2020-07-14 04:20:45 +08:00
] ;
const processor = new IssueProcessor (
opts ,
2021-01-15 20:20:32 +08:00
async ( ) = > 'abot' ,
2020-07-14 04:20:45 +08:00
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num , dt ) = > [ ] ,
async ( issue , label ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toEqual ( 1 ) ;
} ) ;
2021-01-16 21:28:29 +08:00
test ( 'processing a stale issue will close it even if configured not to mark as stale when days-before-issue-stale override days-before-stale' , async ( ) = > {
2021-01-19 18:54:16 +08:00
const opts = {
. . . DefaultProcessorOptions ,
daysBeforeStale : 0 ,
daysBeforeIssueStale : - 1 ,
staleIssueMessage : ''
} ;
2021-01-16 21:28:29 +08:00
const TestIssueList : Issue [ ] = [
2021-01-18 09:22:36 +08:00
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2021-01-18 09:22:36 +08:00
1 ,
'An issue with no label' ,
'2020-01-01T17:00:00Z' ,
'2020-01-01T17:00:00Z' ,
false ,
[ 'Stale' ]
)
2021-01-16 21:28:29 +08:00
] ;
const processor = new IssueProcessor (
opts ,
async ( ) = > 'abot' ,
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num , dt ) = > [ ] ,
async ( issue , label ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toEqual ( 1 ) ;
} ) ;
2020-07-14 04:20:45 +08:00
test ( 'processing a stale PR will close it even if configured not to mark as stale' , async ( ) = > {
2021-01-19 18:54:16 +08:00
const opts = {
. . . DefaultProcessorOptions ,
daysBeforeStale : - 1 ,
stalePrMessage : ''
} ;
2020-07-14 04:20:45 +08:00
const TestIssueList : Issue [ ] = [
2021-01-18 09:22:36 +08:00
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2021-01-18 09:22:36 +08:00
1 ,
'An issue with no label' ,
'2020-01-01T17:00:00Z' ,
'2020-01-01T17:00:00Z' ,
true ,
[ 'Stale' ]
)
2020-07-14 04:20:45 +08:00
] ;
const processor = new IssueProcessor (
opts ,
2021-01-15 20:20:32 +08:00
async ( ) = > 'abot' ,
2020-07-14 04:20:45 +08:00
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num , dt ) = > [ ] ,
async ( issue , label ) = > new Date ( ) . toDateString ( )
2020-04-17 01:57:59 +08:00
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toEqual ( 1 ) ;
} ) ;
2021-01-16 21:28:29 +08:00
test ( 'processing a stale PR will close it even if configured not to mark as stale when days-before-pr-stale override days-before-stale' , async ( ) = > {
2021-01-19 18:54:16 +08:00
const opts = {
. . . DefaultProcessorOptions ,
daysBeforeStale : 0 ,
daysBeforePrStale : - 1 ,
stalePrMessage : ''
} ;
2021-01-16 21:28:29 +08:00
const TestIssueList : Issue [ ] = [
2021-01-18 09:22:36 +08:00
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2021-01-18 09:22:36 +08:00
1 ,
'An issue with no label' ,
'2020-01-01T17:00:00Z' ,
'2020-01-01T17:00:00Z' ,
true ,
[ 'Stale' ]
)
2021-01-16 21:28:29 +08:00
] ;
const processor = new IssueProcessor (
opts ,
async ( ) = > 'abot' ,
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num , dt ) = > [ ] ,
async ( issue , label ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toEqual ( 1 ) ;
} ) ;
2020-04-27 19:53:58 +08:00
test ( 'closed issues will not be marked stale' , async ( ) = > {
const TestIssueList : Issue [ ] = [
2020-05-11 22:46:03 +08:00
generateIssue (
2021-01-19 18:54:16 +08:00
DefaultProcessorOptions ,
2020-05-11 22:46:03 +08:00
1 ,
'A closed issue that will not be marked' ,
'2020-01-01T17:00:00Z' ,
2021-01-18 09:22:36 +08:00
'2020-01-01T17:00:00Z' ,
2020-05-11 22:46:03 +08:00
false ,
[ ] ,
true
)
2020-04-27 19:53:58 +08:00
] ;
2020-05-11 22:46:03 +08:00
const processor = new IssueProcessor (
DefaultProcessorOptions ,
2021-01-15 20:20:32 +08:00
async ( ) = > 'abot' ,
2020-05-11 22:46:03 +08:00
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num , dt ) = > [ ]
2020-04-27 19:53:58 +08:00
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toEqual ( 0 ) ;
} ) ;
test ( 'stale closed issues will not be closed' , async ( ) = > {
const TestIssueList : Issue [ ] = [
2020-05-11 22:46:03 +08:00
generateIssue (
2021-01-19 18:54:16 +08:00
DefaultProcessorOptions ,
2020-05-11 22:46:03 +08:00
1 ,
'A stale closed issue' ,
'2020-01-01T17:00:00Z' ,
2021-01-18 09:22:36 +08:00
'2020-01-01T17:00:00Z' ,
2020-05-11 22:46:03 +08:00
false ,
[ 'Stale' ] ,
true
)
2020-04-27 19:53:58 +08:00
] ;
2020-05-11 22:46:03 +08:00
const processor = new IssueProcessor (
DefaultProcessorOptions ,
2021-01-15 20:20:32 +08:00
async ( ) = > 'abot' ,
2020-05-11 22:46:03 +08:00
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num , dt ) = > [ ] ,
async ( issue , label ) = > new Date ( ) . toDateString ( )
2020-04-27 19:53:58 +08:00
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toEqual ( 0 ) ;
} ) ;
test ( 'closed prs will not be marked stale' , async ( ) = > {
const TestIssueList : Issue [ ] = [
2020-05-11 22:46:03 +08:00
generateIssue (
2021-01-19 18:54:16 +08:00
DefaultProcessorOptions ,
2020-05-11 22:46:03 +08:00
1 ,
'A closed PR that will not be marked' ,
'2020-01-01T17:00:00Z' ,
2021-01-18 09:22:36 +08:00
'2020-01-01T17:00:00Z' ,
2020-05-11 22:46:03 +08:00
true ,
[ ] ,
true
)
2020-04-27 19:53:58 +08:00
] ;
2020-05-11 22:46:03 +08:00
const processor = new IssueProcessor (
DefaultProcessorOptions ,
2021-01-15 20:20:32 +08:00
async ( ) = > 'abot' ,
2020-05-11 22:46:03 +08:00
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num , dt ) = > [ ] ,
async ( issue , label ) = > new Date ( ) . toDateString ( )
2020-04-27 19:53:58 +08:00
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toEqual ( 0 ) ;
} ) ;
test ( 'stale closed prs will not be closed' , async ( ) = > {
const TestIssueList : Issue [ ] = [
2020-05-11 22:46:03 +08:00
generateIssue (
2021-01-19 18:54:16 +08:00
DefaultProcessorOptions ,
2020-05-11 22:46:03 +08:00
1 ,
'A stale closed PR that will not be closed again' ,
'2020-01-01T17:00:00Z' ,
2021-01-18 09:22:36 +08:00
'2020-01-01T17:00:00Z' ,
2020-05-11 22:46:03 +08:00
true ,
[ 'Stale' ] ,
true
)
2020-04-27 19:53:58 +08:00
] ;
2020-05-11 22:46:03 +08:00
const processor = new IssueProcessor (
DefaultProcessorOptions ,
2021-01-15 20:20:32 +08:00
async ( ) = > 'abot' ,
2020-05-11 22:46:03 +08:00
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
2021-01-15 20:35:41 +08:00
async ( num : number , dt : string ) = > [ ] ,
async ( issue : Issue , label : string ) = > new Date ( ) . toDateString ( )
2020-04-27 19:53:58 +08:00
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toEqual ( 0 ) ;
} ) ;
test ( 'locked issues will not be marked stale' , async ( ) = > {
const TestIssueList : Issue [ ] = [
2020-05-11 22:46:03 +08:00
generateIssue (
2021-01-19 18:54:16 +08:00
DefaultProcessorOptions ,
2020-05-11 22:46:03 +08:00
1 ,
'A locked issue that will not be stale' ,
'2020-01-01T17:00:00Z' ,
2021-01-18 09:22:36 +08:00
'2020-01-01T17:00:00Z' ,
2020-05-11 22:46:03 +08:00
false ,
[ ] ,
false ,
true
)
2020-04-27 19:53:58 +08:00
] ;
2021-01-15 20:20:32 +08:00
const processor = new IssueProcessor (
DefaultProcessorOptions ,
async ( ) = > 'abot' ,
2021-01-15 20:35:41 +08:00
async p = > ( p == 1 ? TestIssueList : [ ] )
2020-04-27 19:53:58 +08:00
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toEqual ( 0 ) ;
} ) ;
test ( 'stale locked issues will not be closed' , async ( ) = > {
const TestIssueList : Issue [ ] = [
2020-05-11 22:46:03 +08:00
generateIssue (
2021-01-19 18:54:16 +08:00
DefaultProcessorOptions ,
2020-05-11 22:46:03 +08:00
1 ,
'A stale locked issue that will not be closed' ,
'2020-01-01T17:00:00Z' ,
2021-01-18 09:22:36 +08:00
'2020-01-01T17:00:00Z' ,
2020-05-11 22:46:03 +08:00
false ,
[ 'Stale' ] ,
false ,
true
)
2020-04-27 19:53:58 +08:00
] ;
2020-05-11 22:46:03 +08:00
const processor = new IssueProcessor (
DefaultProcessorOptions ,
2021-01-15 20:20:32 +08:00
async ( ) = > 'abot' ,
2020-05-11 22:46:03 +08:00
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
2021-01-15 20:35:41 +08:00
async ( num : number , dt : string ) = > [ ] ,
async ( issue : Issue , label : string ) = > new Date ( ) . toDateString ( )
2020-04-27 19:53:58 +08:00
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toEqual ( 0 ) ;
} ) ;
test ( 'locked prs will not be marked stale' , async ( ) = > {
const TestIssueList : Issue [ ] = [
2020-05-11 22:46:03 +08:00
generateIssue (
2021-01-19 18:54:16 +08:00
DefaultProcessorOptions ,
2020-05-11 22:46:03 +08:00
1 ,
'A locked PR that will not be marked stale' ,
'2020-01-01T17:00:00Z' ,
2021-01-18 09:22:36 +08:00
'2020-01-01T17:00:00Z' ,
2020-05-11 22:46:03 +08:00
true ,
[ ] ,
false ,
true
)
2020-04-27 19:53:58 +08:00
] ;
2021-01-15 20:20:32 +08:00
const processor = new IssueProcessor (
DefaultProcessorOptions ,
async ( ) = > 'abot' ,
2021-01-15 20:35:41 +08:00
async p = > ( p == 1 ? TestIssueList : [ ] )
2020-04-27 19:53:58 +08:00
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toEqual ( 0 ) ;
} ) ;
test ( 'stale locked prs will not be closed' , async ( ) = > {
const TestIssueList : Issue [ ] = [
2020-05-11 22:46:03 +08:00
generateIssue (
2021-01-19 18:54:16 +08:00
DefaultProcessorOptions ,
2020-05-11 22:46:03 +08:00
1 ,
'A stale locked PR that will not be closed' ,
'2020-01-01T17:00:00Z' ,
2021-01-18 09:22:36 +08:00
'2020-01-01T17:00:00Z' ,
2020-05-11 22:46:03 +08:00
true ,
[ 'Stale' ] ,
false ,
true
)
2020-04-27 19:53:58 +08:00
] ;
2020-05-11 22:46:03 +08:00
const processor = new IssueProcessor (
DefaultProcessorOptions ,
2021-01-15 20:20:32 +08:00
async ( ) = > 'abot' ,
2020-05-11 22:46:03 +08:00
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
2021-01-15 20:35:41 +08:00
async ( num : number , dt : string ) = > [ ] ,
async ( issue : Issue , label : string ) = > new Date ( ) . toDateString ( )
2020-04-27 19:53:58 +08:00
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toEqual ( 0 ) ;
} ) ;
2020-04-17 01:57:59 +08:00
test ( 'exempt issue labels will not be marked stale' , async ( ) = > {
2021-01-17 09:13:19 +08:00
expect . assertions ( 3 ) ;
2021-01-19 18:54:16 +08:00
const opts = { . . . DefaultProcessorOptions } ;
opts . exemptIssueLabels = 'Exempt' ;
2020-04-17 01:57:59 +08:00
const TestIssueList : Issue [ ] = [
2021-01-18 09:22:36 +08:00
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2021-01-18 09:22:36 +08:00
1 ,
'My first issue' ,
'2020-01-01T17:00:00Z' ,
'2020-01-01T17:00:00Z' ,
false ,
[ 'Exempt' ]
)
2020-04-17 01:57:59 +08:00
] ;
2020-05-11 22:46:03 +08:00
const processor = new IssueProcessor (
opts ,
2021-01-15 20:20:32 +08:00
async ( ) = > 'abot' ,
2020-05-11 22:46:03 +08:00
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
2021-01-15 20:35:41 +08:00
async ( num : number , dt : string ) = > [ ] ,
async ( issue : Issue , label : string ) = > new Date ( ) . toDateString ( )
2020-04-17 01:57:59 +08:00
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
2021-01-17 09:13:19 +08:00
expect ( processor . staleIssues . length ) . toStrictEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toStrictEqual ( 0 ) ;
expect ( processor . removedLabelIssues . length ) . toStrictEqual ( 0 ) ;
2020-04-17 01:57:59 +08:00
} ) ;
test ( 'exempt issue labels will not be marked stale (multi issue label with spaces)' , async ( ) = > {
2021-01-19 18:54:16 +08:00
const opts = { . . . DefaultProcessorOptions } ;
opts . exemptIssueLabels = 'Exempt, Cool, None' ;
2020-04-17 01:57:59 +08:00
const TestIssueList : Issue [ ] = [
2021-01-18 09:22:36 +08:00
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2021-01-18 09:22:36 +08:00
1 ,
'My first issue' ,
'2020-01-01T17:00:00Z' ,
'2020-01-01T17:00:00Z' ,
false ,
[ 'Cool' ]
)
2020-04-17 01:57:59 +08:00
] ;
2020-05-11 22:46:03 +08:00
const processor = new IssueProcessor (
opts ,
2021-01-15 20:20:32 +08:00
async ( ) = > 'abot' ,
2020-05-11 22:46:03 +08:00
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
2021-01-15 20:35:41 +08:00
async ( num : number , dt : string ) = > [ ] ,
async ( issue : Issue , label : string ) = > new Date ( ) . toDateString ( )
2020-04-17 01:57:59 +08:00
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toEqual ( 0 ) ;
} ) ;
test ( 'exempt issue labels will not be marked stale (multi issue label)' , async ( ) = > {
2021-01-19 18:54:16 +08:00
const opts = { . . . DefaultProcessorOptions } ;
opts . exemptIssueLabels = 'Exempt,Cool,None' ;
2020-04-17 01:57:59 +08:00
const TestIssueList : Issue [ ] = [
2021-01-18 09:22:36 +08:00
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2021-01-18 09:22:36 +08:00
1 ,
'My first issue' ,
'2020-01-01T17:00:00Z' ,
'2020-01-01T17:00:00Z' ,
false ,
[ 'Cool' ]
)
2020-04-17 01:57:59 +08:00
] ;
2020-05-11 22:46:03 +08:00
const processor = new IssueProcessor (
opts ,
2021-01-15 20:20:32 +08:00
async ( ) = > 'abot' ,
2020-05-11 22:46:03 +08:00
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
2021-01-15 20:35:41 +08:00
async ( num : number , dt : string ) = > [ ] ,
async ( issue : Issue , label : string ) = > new Date ( ) . toDateString ( )
2020-04-17 01:57:59 +08:00
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toEqual ( 0 ) ;
2020-05-26 21:16:38 +08:00
expect ( processor . removedLabelIssues . length ) . toEqual ( 0 ) ;
2020-04-17 01:57:59 +08:00
} ) ;
test ( 'exempt pr labels will not be marked stale' , async ( ) = > {
2021-01-19 18:54:16 +08:00
const opts = { . . . DefaultProcessorOptions } ;
opts . exemptIssueLabels = 'Cool' ;
2020-04-17 01:57:59 +08:00
const TestIssueList : Issue [ ] = [
2021-01-18 09:22:36 +08:00
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2021-01-18 09:22:36 +08:00
1 ,
'My first issue' ,
'2020-01-01T17:00:00Z' ,
'2020-01-01T17:00:00Z' ,
false ,
[ 'Cool' ]
) ,
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2021-01-18 09:22:36 +08:00
2 ,
'My first PR' ,
'2020-01-01T17:00:00Z' ,
'2020-01-01T17:00:00Z' ,
true ,
[ 'Cool' ]
) ,
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2021-01-18 09:22:36 +08:00
3 ,
'Another issue' ,
'2020-01-01T17:00:00Z' ,
'2020-01-01T17:00:00Z' ,
false
)
2020-04-17 01:57:59 +08:00
] ;
2020-05-11 22:46:03 +08:00
const processor = new IssueProcessor (
opts ,
2021-01-15 20:20:32 +08:00
async ( ) = > 'abot' ,
2020-05-11 22:46:03 +08:00
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
2021-01-15 20:35:41 +08:00
async ( num : number , dt : string ) = > [ ] ,
async ( issue : Issue , label : string ) = > new Date ( ) . toDateString ( )
2020-04-17 01:57:59 +08:00
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toEqual ( 2 ) ; // PR should get processed even though it has an exempt **issue** label
2019-08-04 09:34:59 +08:00
} ) ;
2020-04-17 02:23:28 +08:00
2021-01-17 09:13:19 +08:00
test ( 'exempt issue labels will not be marked stale and will remove the existing stale label' , async ( ) = > {
expect . assertions ( 3 ) ;
2021-01-19 18:54:16 +08:00
const opts = { . . . DefaultProcessorOptions } ;
opts . exemptIssueLabels = 'Exempt' ;
2021-01-17 09:13:19 +08:00
const TestIssueList : Issue [ ] = [
2021-01-18 09:22:36 +08:00
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2021-01-18 09:22:36 +08:00
1 ,
'My first issue' ,
'2020-01-01T17:00:00Z' ,
'2020-01-01T17:00:00Z' ,
false ,
[ 'Exempt' , 'Stale' ]
)
2021-01-17 09:13:19 +08:00
] ;
const processor = new IssueProcessor (
opts ,
async ( ) = > 'abot' ,
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num : number , dt : string ) = > [
{
user : {
login : 'notme' ,
type : 'User'
}
}
] , // return a fake comment to indicate there was an update
async ( issue : Issue , label : string ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toStrictEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toStrictEqual ( 0 ) ;
expect ( processor . removedLabelIssues . length ) . toStrictEqual ( 1 ) ;
} ) ;
2020-04-17 02:23:28 +08:00
test ( 'stale issues should not be closed if days is set to -1' , async ( ) = > {
2021-01-19 18:54:16 +08:00
const opts = { . . . DefaultProcessorOptions } ;
opts . daysBeforeClose = - 1 ;
2020-04-17 02:23:28 +08:00
const TestIssueList : Issue [ ] = [
2021-01-18 09:22:36 +08:00
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2021-01-18 09:22:36 +08:00
1 ,
'My first issue' ,
'2020-01-01T17:00:00Z' ,
'2020-01-01T17:00:00Z' ,
false ,
[ 'Stale' ]
) ,
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2021-01-18 09:22:36 +08:00
2 ,
'My first PR' ,
'2020-01-01T17:00:00Z' ,
'2020-01-01T17:00:00Z' ,
true ,
[ 'Stale' ]
) ,
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2021-01-18 09:22:36 +08:00
3 ,
'Another issue' ,
'2020-01-01T17:00:00Z' ,
'2020-01-01T17:00:00Z' ,
false ,
[ 'Stale' ]
)
2020-04-17 02:23:28 +08:00
] ;
2020-05-11 22:46:03 +08:00
const processor = new IssueProcessor (
opts ,
2021-01-15 20:20:32 +08:00
async ( ) = > 'abot' ,
2020-05-11 22:46:03 +08:00
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
2021-01-15 20:35:41 +08:00
async ( num : number , dt : string ) = > [ ] ,
async ( issue : Issue , label : string ) = > new Date ( ) . toDateString ( )
2020-04-17 02:23:28 +08:00
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . closedIssues . length ) . toEqual ( 0 ) ;
2020-05-26 21:16:38 +08:00
expect ( processor . removedLabelIssues . length ) . toEqual ( 0 ) ;
2020-04-17 02:23:28 +08:00
} ) ;
2020-05-11 22:46:03 +08:00
test ( 'stale label should be removed if a comment was added to a stale issue' , async ( ) = > {
2021-01-19 18:54:16 +08:00
const opts = { . . . DefaultProcessorOptions } ;
opts . removeStaleWhenUpdated = true ;
2020-05-11 22:46:03 +08:00
const TestIssueList : Issue [ ] = [
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2020-05-11 22:46:03 +08:00
1 ,
'An issue that should un-stale' ,
'2020-01-01T17:00:00Z' ,
2021-01-18 09:22:36 +08:00
'2020-01-01T17:00:00Z' ,
2020-05-11 22:46:03 +08:00
false ,
[ 'Stale' ]
)
] ;
const processor = new IssueProcessor (
opts ,
2021-01-15 20:20:32 +08:00
async ( ) = > 'abot' ,
2020-05-11 22:46:03 +08:00
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
2021-01-16 21:28:29 +08:00
async ( num : number , dt : string ) = > [
{
user : {
login : 'notme' ,
type : 'User'
}
}
] , // return a fake comment to indicate there was an update
2021-01-15 20:35:41 +08:00
async ( issue : Issue , label : string ) = > new Date ( ) . toDateString ( )
2020-05-11 22:46:03 +08:00
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . closedIssues . length ) . toEqual ( 0 ) ;
expect ( processor . staleIssues . length ) . toEqual ( 0 ) ;
expect ( processor . removedLabelIssues . length ) . toEqual ( 1 ) ;
} ) ;
2020-05-19 08:08:31 +08:00
2020-05-19 08:33:59 +08:00
test ( 'stale label should not be removed if a comment was added by the bot (and the issue should be closed)' , async ( ) = > {
2021-01-19 18:54:16 +08:00
const opts = { . . . DefaultProcessorOptions } ;
opts . removeStaleWhenUpdated = true ;
2020-05-19 08:33:59 +08:00
github . context . actor = 'abot' ;
const TestIssueList : Issue [ ] = [
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2020-05-19 08:33:59 +08:00
1 ,
'An issue that should stay stale' ,
'2020-01-01T17:00:00Z' ,
2021-01-18 09:22:36 +08:00
'2020-01-01T17:00:00Z' ,
2020-05-19 08:33:59 +08:00
false ,
[ 'Stale' ]
)
] ;
const processor = new IssueProcessor (
opts ,
2021-01-15 20:20:32 +08:00
async ( ) = > 'abot' ,
2020-05-19 08:33:59 +08:00
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
2021-01-16 21:28:29 +08:00
async ( num : number , dt : string ) = > [
{
user : {
login : 'abot' ,
type : 'User'
}
}
] , // return a fake comment to indicate there was an update by the bot
2021-01-15 20:35:41 +08:00
async ( issue : Issue , label : string ) = > new Date ( ) . toDateString ( )
2020-05-19 08:33:59 +08:00
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . closedIssues . length ) . toEqual ( 1 ) ;
expect ( processor . staleIssues . length ) . toEqual ( 0 ) ;
expect ( processor . removedLabelIssues . length ) . toEqual ( 0 ) ;
} ) ;
2021-01-15 19:51:24 +08:00
test ( 'stale label containing a space should be removed if a comment was added to a stale issue' , async ( ) = > {
2021-01-19 18:54:16 +08:00
const opts : IssueProcessorOptions = {
. . . DefaultProcessorOptions ,
removeStaleWhenUpdated : true ,
staleIssueLabel : 'stat: stale'
} ;
2021-01-15 19:51:24 +08:00
const TestIssueList : Issue [ ] = [
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2021-01-15 19:51:24 +08:00
1 ,
'An issue that should un-stale' ,
'2020-01-01T17:00:00Z' ,
2021-01-18 09:22:36 +08:00
'2020-01-01T17:00:00Z' ,
2021-01-15 19:51:24 +08:00
false ,
[ 'stat: stale' ]
)
] ;
const processor = new IssueProcessor (
opts ,
2021-01-15 20:35:41 +08:00
async ( ) = > 'abot' ,
2021-01-15 19:51:24 +08:00
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
2021-01-15 20:35:41 +08:00
async ( num : number , dt : string ) = > [ { user : { login : 'notme' , type : 'User' } } ] , // return a fake comment to indicate there was an update
async ( issue : Issue , label : string ) = > new Date ( ) . toDateString ( )
2021-01-15 19:51:24 +08:00
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . closedIssues . length ) . toEqual ( 0 ) ;
expect ( processor . staleIssues . length ) . toEqual ( 0 ) ;
expect ( processor . removedLabelIssues . length ) . toEqual ( 1 ) ;
} ) ;
2020-05-19 08:08:31 +08:00
test ( 'stale issues should not be closed until after the closed number of days' , async ( ) = > {
2021-01-19 18:54:16 +08:00
const opts = { . . . DefaultProcessorOptions } ;
opts . daysBeforeStale = 5 ; // stale after 5 days
opts . daysBeforeClose = 1 ; // closes after 6 days
2020-05-19 08:08:31 +08:00
let lastUpdate = new Date ( ) ;
lastUpdate . setDate ( lastUpdate . getDate ( ) - 5 ) ;
const TestIssueList : Issue [ ] = [
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2020-05-19 08:08:31 +08:00
1 ,
'An issue that should be marked stale but not closed' ,
lastUpdate . toString ( ) ,
2021-01-18 09:22:36 +08:00
lastUpdate . toString ( ) ,
2020-05-19 08:08:31 +08:00
false
)
] ;
const processor = new IssueProcessor (
opts ,
2021-01-15 20:20:32 +08:00
async ( ) = > 'abot' ,
2020-05-19 08:08:31 +08:00
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num , dt ) = > [ ] ,
async ( issue , label ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . closedIssues . length ) . toEqual ( 0 ) ;
2020-05-26 21:16:38 +08:00
expect ( processor . removedLabelIssues . length ) . toEqual ( 0 ) ;
2020-05-19 08:08:31 +08:00
expect ( processor . staleIssues . length ) . toEqual ( 1 ) ;
} ) ;
test ( 'stale issues should be closed if the closed nubmer of days (additive) is also passed' , async ( ) = > {
2021-01-19 18:54:16 +08:00
const opts = { . . . DefaultProcessorOptions } ;
opts . daysBeforeStale = 5 ; // stale after 5 days
opts . daysBeforeClose = 1 ; // closes after 6 days
2020-05-19 08:08:31 +08:00
let lastUpdate = new Date ( ) ;
lastUpdate . setDate ( lastUpdate . getDate ( ) - 7 ) ;
const TestIssueList : Issue [ ] = [
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2020-05-19 08:08:31 +08:00
1 ,
'An issue that should be stale and closed' ,
lastUpdate . toString ( ) ,
2021-01-18 09:22:36 +08:00
lastUpdate . toString ( ) ,
2020-05-19 08:08:31 +08:00
false ,
[ 'Stale' ]
)
] ;
const processor = new IssueProcessor (
opts ,
2021-01-15 20:20:32 +08:00
async ( ) = > 'abot' ,
2020-05-19 08:08:31 +08:00
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
2021-01-15 20:35:41 +08:00
async ( num : number , dt : string ) = > [ ] ,
async ( issue : Issue , label : string ) = > new Date ( ) . toDateString ( )
2020-05-19 08:08:31 +08:00
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . closedIssues . length ) . toEqual ( 1 ) ;
2020-05-26 21:16:38 +08:00
expect ( processor . removedLabelIssues . length ) . toEqual ( 0 ) ;
2020-05-19 08:08:31 +08:00
expect ( processor . staleIssues . length ) . toEqual ( 0 ) ;
} ) ;
2020-05-26 21:16:38 +08:00
test ( 'stale issues should not be closed until after the closed number of days (long)' , async ( ) = > {
2021-01-19 18:54:16 +08:00
const opts = { . . . DefaultProcessorOptions } ;
opts . daysBeforeStale = 5 ; // stale after 5 days
opts . daysBeforeClose = 20 ; // closes after 25 days
2020-05-26 21:16:38 +08:00
let lastUpdate = new Date ( ) ;
lastUpdate . setDate ( lastUpdate . getDate ( ) - 10 ) ;
const TestIssueList : Issue [ ] = [
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2020-05-26 21:16:38 +08:00
1 ,
'An issue that should be marked stale but not closed' ,
lastUpdate . toString ( ) ,
2021-01-18 09:22:36 +08:00
lastUpdate . toString ( ) ,
2020-05-26 21:16:38 +08:00
false
)
] ;
const processor = new IssueProcessor (
opts ,
2021-01-15 20:20:32 +08:00
async ( ) = > 'abot' ,
2020-05-26 21:16:38 +08:00
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num , dt ) = > [ ] ,
async ( issue , label ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . closedIssues . length ) . toEqual ( 0 ) ;
expect ( processor . removedLabelIssues . length ) . toEqual ( 0 ) ;
expect ( processor . staleIssues . length ) . toEqual ( 1 ) ;
} ) ;
2020-07-24 20:08:48 +08:00
test ( 'skips stale message on issues when skip-stale-issue-message is set' , async ( ) = > {
2021-01-19 18:54:16 +08:00
const opts = { . . . DefaultProcessorOptions } ;
opts . daysBeforeStale = 5 ; // stale after 5 days
opts . daysBeforeClose = 20 ; // closes after 25 days
opts . skipStaleIssueMessage = true ;
2020-07-24 20:08:48 +08:00
let lastUpdate = new Date ( ) ;
lastUpdate . setDate ( lastUpdate . getDate ( ) - 10 ) ;
const TestIssueList : Issue [ ] = [
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2020-07-24 20:08:48 +08:00
1 ,
'An issue that should be marked stale but not closed' ,
lastUpdate . toString ( ) ,
2021-01-18 09:22:36 +08:00
lastUpdate . toString ( ) ,
2020-07-24 20:08:48 +08:00
false
)
] ;
const processor = new IssueProcessor (
opts ,
2021-01-15 20:20:32 +08:00
async ( ) = > 'abot' ,
2020-07-24 20:08:48 +08:00
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
2021-01-15 20:35:41 +08:00
async ( num : number , dt : string ) = > [ ] ,
async ( issue : Issue , label : string ) = > new Date ( ) . toDateString ( )
2020-07-24 20:08:48 +08:00
) ;
// for sake of testing, mocking private function
2021-01-17 09:13:19 +08:00
const markSpy = jest . spyOn ( processor as any , '_markStale' ) ;
2020-07-24 20:08:48 +08:00
await processor . processIssues ( 1 ) ;
// issue should be staled
expect ( processor . closedIssues . length ) . toEqual ( 0 ) ;
expect ( processor . removedLabelIssues . length ) . toEqual ( 0 ) ;
expect ( processor . staleIssues . length ) . toEqual ( 1 ) ;
// comment should not be created
expect ( markSpy ) . toHaveBeenCalledWith (
TestIssueList [ 0 ] ,
opts . staleIssueMessage ,
opts . staleIssueLabel ,
// this option is skipMessage
true
) ;
} ) ;
test ( 'skips stale message on prs when skip-stale-pr-message is set' , async ( ) = > {
2021-01-19 18:54:16 +08:00
const opts = { . . . DefaultProcessorOptions } ;
opts . daysBeforeStale = 5 ; // stale after 5 days
opts . daysBeforeClose = 20 ; // closes after 25 days
opts . skipStalePrMessage = true ;
2020-07-24 20:08:48 +08:00
let lastUpdate = new Date ( ) ;
lastUpdate . setDate ( lastUpdate . getDate ( ) - 10 ) ;
const TestIssueList : Issue [ ] = [
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2020-07-24 20:08:48 +08:00
1 ,
'An issue that should be marked stale but not closed' ,
lastUpdate . toString ( ) ,
2021-01-18 09:22:36 +08:00
lastUpdate . toString ( ) ,
2020-07-24 20:08:48 +08:00
true
)
] ;
const processor = new IssueProcessor (
opts ,
2021-01-15 20:20:32 +08:00
async ( ) = > 'abot' ,
2020-07-24 20:08:48 +08:00
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
2021-01-15 20:35:41 +08:00
async ( num : number , dt : string ) = > [ ] ,
async ( issue : Issue , label : string ) = > new Date ( ) . toDateString ( )
2020-07-24 20:08:48 +08:00
) ;
// for sake of testing, mocking private function
2021-01-17 09:13:19 +08:00
const markSpy = jest . spyOn ( processor as any , '_markStale' ) ;
2020-07-24 20:08:48 +08:00
await processor . processIssues ( 1 ) ;
// issue should be staled
expect ( processor . closedIssues . length ) . toEqual ( 0 ) ;
expect ( processor . removedLabelIssues . length ) . toEqual ( 0 ) ;
expect ( processor . staleIssues . length ) . toEqual ( 1 ) ;
// comment should not be created
expect ( markSpy ) . toHaveBeenCalledWith (
TestIssueList [ 0 ] ,
opts . stalePrMessage ,
opts . stalePrLabel ,
// this option is skipMessage
true
) ;
} ) ;
test ( 'not providing state takes precedence over skipStaleIssueMessage' , async ( ) = > {
2021-01-19 18:54:16 +08:00
const opts = { . . . DefaultProcessorOptions } ;
opts . daysBeforeStale = 5 ; // stale after 5 days
opts . daysBeforeClose = 20 ; // closes after 25 days
opts . skipStalePrMessage = true ;
opts . staleIssueMessage = '' ;
2020-07-24 20:08:48 +08:00
let lastUpdate = new Date ( ) ;
lastUpdate . setDate ( lastUpdate . getDate ( ) - 10 ) ;
const TestIssueList : Issue [ ] = [
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2020-07-24 20:08:48 +08:00
1 ,
'An issue that should be marked stale but not closed' ,
lastUpdate . toString ( ) ,
2021-01-18 09:22:36 +08:00
lastUpdate . toString ( ) ,
2020-07-24 20:08:48 +08:00
false
)
] ;
const processor = new IssueProcessor (
opts ,
2021-01-15 20:20:32 +08:00
async ( ) = > 'abot' ,
2020-07-24 20:08:48 +08:00
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
2021-01-15 20:35:41 +08:00
async ( num : number , dt : string ) = > [ ] ,
async ( issue : Issue , label : string ) = > new Date ( ) . toDateString ( )
2020-07-24 20:08:48 +08:00
) ;
await processor . processIssues ( 1 ) ;
// issue should be staled
expect ( processor . closedIssues . length ) . toEqual ( 0 ) ;
expect ( processor . removedLabelIssues . length ) . toEqual ( 0 ) ;
expect ( processor . staleIssues . length ) . toEqual ( 0 ) ;
} ) ;
test ( 'not providing stalePrMessage takes precedence over skipStalePrMessage' , async ( ) = > {
2021-01-19 18:54:16 +08:00
const opts = { . . . DefaultProcessorOptions } ;
opts . daysBeforeStale = 5 ; // stale after 5 days
opts . daysBeforeClose = 20 ; // closes after 25 days
opts . skipStalePrMessage = true ;
opts . stalePrMessage = '' ;
2020-07-24 20:08:48 +08:00
let lastUpdate = new Date ( ) ;
lastUpdate . setDate ( lastUpdate . getDate ( ) - 10 ) ;
const TestIssueList : Issue [ ] = [
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2020-07-24 20:08:48 +08:00
1 ,
'An issue that should be marked stale but not closed' ,
lastUpdate . toString ( ) ,
2021-01-18 09:22:36 +08:00
lastUpdate . toString ( ) ,
2020-07-24 20:08:48 +08:00
true
)
] ;
const processor = new IssueProcessor (
opts ,
2021-01-15 20:20:32 +08:00
async ( ) = > 'abot' ,
2020-07-24 20:08:48 +08:00
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
2021-01-15 20:35:41 +08:00
async ( num : number , dt : string ) = > [ ] ,
async ( issue : Issue , label : string ) = > new Date ( ) . toDateString ( )
2020-07-24 20:08:48 +08:00
) ;
await processor . processIssues ( 1 ) ;
// issue should be staled
expect ( processor . closedIssues . length ) . toEqual ( 0 ) ;
expect ( processor . removedLabelIssues . length ) . toEqual ( 0 ) ;
expect ( processor . staleIssues . length ) . toEqual ( 0 ) ;
} ) ;
2021-01-15 19:49:38 +08:00
test ( 'git branch is deleted when option is enabled' , async ( ) = > {
const opts = { . . . DefaultProcessorOptions , deleteBranch : true } ;
const isPullRequest = true ;
const TestIssueList : Issue [ ] = [
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2021-01-15 19:49:38 +08:00
1 ,
'An issue that should have its branch deleted' ,
'2020-01-01T17:00:00Z' ,
2021-01-18 09:22:36 +08:00
'2020-01-01T17:00:00Z' ,
2021-01-15 19:49:38 +08:00
isPullRequest ,
[ 'Stale' ]
)
] ;
const processor = new IssueProcessor (
opts ,
2021-01-15 20:35:41 +08:00
async ( ) = > 'abot' ,
2021-01-15 19:49:38 +08:00
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
2021-01-15 20:35:41 +08:00
async ( num : number , dt : string ) = > [ ] ,
async ( issue : Issue , label : string ) = > new Date ( ) . toDateString ( )
2021-01-15 19:49:38 +08:00
) ;
await processor . processIssues ( 1 ) ;
expect ( processor . closedIssues . length ) . toEqual ( 1 ) ;
expect ( processor . removedLabelIssues . length ) . toEqual ( 0 ) ;
expect ( processor . staleIssues . length ) . toEqual ( 0 ) ;
expect ( processor . deletedBranchIssues . length ) . toEqual ( 1 ) ;
} ) ;
test ( 'git branch is not deleted when issue is not pull request' , async ( ) = > {
const opts = { . . . DefaultProcessorOptions , deleteBranch : true } ;
const isPullRequest = false ;
const TestIssueList : Issue [ ] = [
generateIssue (
2021-01-19 18:54:16 +08:00
opts ,
2021-01-15 19:49:38 +08:00
1 ,
'An issue that should not have its branch deleted' ,
'2020-01-01T17:00:00Z' ,
2021-01-18 09:22:36 +08:00
'2020-01-01T17:00:00Z' ,
2021-01-15 19:49:38 +08:00
isPullRequest ,
[ 'Stale' ]
)
] ;
const processor = new IssueProcessor (
opts ,
2021-01-15 20:35:41 +08:00
async ( ) = > 'abot' ,
2021-01-15 19:49:38 +08:00
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
2021-01-15 20:35:41 +08:00
async ( num : number , dt : string ) = > [ ] ,
async ( issue : Issue , label : string ) = > new Date ( ) . toDateString ( )
2021-01-15 19:49:38 +08:00
) ;
await processor . processIssues ( 1 ) ;
expect ( processor . closedIssues . length ) . toEqual ( 1 ) ;
expect ( processor . removedLabelIssues . length ) . toEqual ( 0 ) ;
expect ( processor . staleIssues . length ) . toEqual ( 0 ) ;
expect ( processor . deletedBranchIssues . length ) . toEqual ( 0 ) ;
} ) ;
2021-01-19 18:54:16 +08:00
test ( 'an issue without a milestone will be marked as stale' , async ( ) = > {
expect . assertions ( 3 ) ;
const TestIssueList : Issue [ ] = [
generateIssue (
DefaultProcessorOptions ,
1 ,
'My first issue' ,
'2020-01-01T17:00:00Z' ,
'2020-01-01T17:00:00Z' ,
false ,
undefined ,
undefined ,
undefined ,
''
)
] ;
const processor = new IssueProcessor (
DefaultProcessorOptions ,
async ( ) = > 'abot' ,
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num : number , dt : string ) = > [ ] ,
async ( issue : Issue , label : string ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toStrictEqual ( 1 ) ;
expect ( processor . closedIssues . length ) . toStrictEqual ( 0 ) ;
expect ( processor . removedLabelIssues . length ) . toStrictEqual ( 0 ) ;
} ) ;
test ( 'an issue without an exempted milestone will be marked as stale' , async ( ) = > {
expect . assertions ( 3 ) ;
const opts = { . . . DefaultProcessorOptions } ;
opts . exemptMilestones = 'Milestone1' ;
const TestIssueList : Issue [ ] = [
generateIssue (
opts ,
1 ,
'My first issue' ,
'2020-01-01T17:00:00Z' ,
'2020-01-01T17:00:00Z' ,
false ,
undefined ,
undefined ,
undefined ,
'Milestone'
)
] ;
const processor = new IssueProcessor (
opts ,
async ( ) = > 'abot' ,
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num : number , dt : string ) = > [ ] ,
async ( issue : Issue , label : string ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toStrictEqual ( 1 ) ;
expect ( processor . closedIssues . length ) . toStrictEqual ( 0 ) ;
expect ( processor . removedLabelIssues . length ) . toStrictEqual ( 0 ) ;
} ) ;
test ( 'an issue with an exempted milestone will not be marked as stale' , async ( ) = > {
expect . assertions ( 3 ) ;
const opts = { . . . DefaultProcessorOptions } ;
opts . exemptMilestones = 'Milestone1' ;
const TestIssueList : Issue [ ] = [
generateIssue (
opts ,
1 ,
'My first issue' ,
'2020-01-01T17:00:00Z' ,
'2020-01-01T17:00:00Z' ,
false ,
undefined ,
undefined ,
undefined ,
'Milestone1'
)
] ;
const processor = new IssueProcessor (
opts ,
async ( ) = > 'abot' ,
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num : number , dt : string ) = > [ ] ,
async ( issue : Issue , label : string ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toStrictEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toStrictEqual ( 0 ) ;
expect ( processor . removedLabelIssues . length ) . toStrictEqual ( 0 ) ;
} ) ;
test ( 'an issue with an exempted milestone will not be marked as stale (multi milestones with spaces)' , async ( ) = > {
expect . assertions ( 3 ) ;
const opts = { . . . DefaultProcessorOptions } ;
opts . exemptMilestones = 'Milestone1, Milestone2' ;
const TestIssueList : Issue [ ] = [
generateIssue (
opts ,
1 ,
'My first issue' ,
'2020-01-01T17:00:00Z' ,
'2020-01-01T17:00:00Z' ,
false ,
undefined ,
undefined ,
undefined ,
'Milestone2'
)
] ;
const processor = new IssueProcessor (
opts ,
async ( ) = > 'abot' ,
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num : number , dt : string ) = > [ ] ,
async ( issue : Issue , label : string ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toStrictEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toStrictEqual ( 0 ) ;
expect ( processor . removedLabelIssues . length ) . toStrictEqual ( 0 ) ;
} ) ;
test ( 'an issue with an exempted milestone will not be marked as stale (multi milestones without spaces)' , async ( ) = > {
expect . assertions ( 3 ) ;
const opts = { . . . DefaultProcessorOptions } ;
opts . exemptMilestones = 'Milestone1,Milestone2' ;
const TestIssueList : Issue [ ] = [
generateIssue (
opts ,
1 ,
'My first issue' ,
'2020-01-01T17:00:00Z' ,
'2020-01-01T17:00:00Z' ,
false ,
undefined ,
undefined ,
undefined ,
'Milestone2'
)
] ;
const processor = new IssueProcessor (
opts ,
async ( ) = > 'abot' ,
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num : number , dt : string ) = > [ ] ,
async ( issue : Issue , label : string ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toStrictEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toStrictEqual ( 0 ) ;
expect ( processor . removedLabelIssues . length ) . toStrictEqual ( 0 ) ;
} ) ;
test ( 'an issue with an exempted milestone but without an exempted issue milestone will not be marked as stale' , async ( ) = > {
expect . assertions ( 3 ) ;
const opts = { . . . DefaultProcessorOptions } ;
opts . exemptMilestones = 'Milestone1' ;
opts . exemptIssueMilestones = '' ;
const TestIssueList : Issue [ ] = [
generateIssue (
opts ,
1 ,
'My first issue' ,
'2020-01-01T17:00:00Z' ,
'2020-01-01T17:00:00Z' ,
false ,
undefined ,
undefined ,
undefined ,
'Milestone1'
)
] ;
const processor = new IssueProcessor (
opts ,
async ( ) = > 'abot' ,
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num : number , dt : string ) = > [ ] ,
async ( issue : Issue , label : string ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toStrictEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toStrictEqual ( 0 ) ;
expect ( processor . removedLabelIssues . length ) . toStrictEqual ( 0 ) ;
} ) ;
test ( 'an issue with an exempted milestone but with another exempted issue milestone will be marked as stale' , async ( ) = > {
expect . assertions ( 3 ) ;
const opts = { . . . DefaultProcessorOptions } ;
opts . exemptMilestones = 'Milestone1' ;
opts . exemptIssueMilestones = 'Milestone2' ;
const TestIssueList : Issue [ ] = [
generateIssue (
opts ,
1 ,
'My first issue' ,
'2020-01-01T17:00:00Z' ,
'2020-01-01T17:00:00Z' ,
false ,
undefined ,
undefined ,
undefined ,
'Milestone1'
)
] ;
const processor = new IssueProcessor (
opts ,
async ( ) = > 'abot' ,
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num : number , dt : string ) = > [ ] ,
async ( issue : Issue , label : string ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toStrictEqual ( 1 ) ;
expect ( processor . closedIssues . length ) . toStrictEqual ( 0 ) ;
expect ( processor . removedLabelIssues . length ) . toStrictEqual ( 0 ) ;
} ) ;
test ( 'an issue with an exempted milestone and with an exempted issue milestone will not be marked as stale' , async ( ) = > {
expect . assertions ( 3 ) ;
const opts = { . . . DefaultProcessorOptions } ;
opts . exemptMilestones = 'Milestone1' ;
opts . exemptIssueMilestones = 'Milestone1' ;
const TestIssueList : Issue [ ] = [
generateIssue (
opts ,
1 ,
'My first issue' ,
'2020-01-01T17:00:00Z' ,
'2020-01-01T17:00:00Z' ,
false ,
undefined ,
undefined ,
undefined ,
'Milestone1'
)
] ;
const processor = new IssueProcessor (
opts ,
async ( ) = > 'abot' ,
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num : number , dt : string ) = > [ ] ,
async ( issue : Issue , label : string ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toStrictEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toStrictEqual ( 0 ) ;
expect ( processor . removedLabelIssues . length ) . toStrictEqual ( 0 ) ;
} ) ;
test ( 'a PR without a milestone will be marked as stale' , async ( ) = > {
expect . assertions ( 3 ) ;
const TestIssueList : Issue [ ] = [
generateIssue (
DefaultProcessorOptions ,
1 ,
'My first issue' ,
'2020-01-01T17:00:00Z' ,
'2020-01-01T17:00:00Z' ,
true ,
undefined ,
undefined ,
undefined ,
''
)
] ;
const processor = new IssueProcessor (
DefaultProcessorOptions ,
async ( ) = > 'abot' ,
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num : number , dt : string ) = > [ ] ,
async ( issue : Issue , label : string ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toStrictEqual ( 1 ) ;
expect ( processor . closedIssues . length ) . toStrictEqual ( 0 ) ;
expect ( processor . removedLabelIssues . length ) . toStrictEqual ( 0 ) ;
} ) ;
test ( 'a PR without an exempted milestone will be marked as stale' , async ( ) = > {
expect . assertions ( 3 ) ;
const opts = { . . . DefaultProcessorOptions } ;
opts . exemptMilestones = 'Milestone1' ;
const TestIssueList : Issue [ ] = [
generateIssue (
opts ,
1 ,
'My first issue' ,
'2020-01-01T17:00:00Z' ,
'2020-01-01T17:00:00Z' ,
true ,
undefined ,
undefined ,
undefined ,
'Milestone'
)
] ;
const processor = new IssueProcessor (
opts ,
async ( ) = > 'abot' ,
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num : number , dt : string ) = > [ ] ,
async ( issue : Issue , label : string ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toStrictEqual ( 1 ) ;
expect ( processor . closedIssues . length ) . toStrictEqual ( 0 ) ;
expect ( processor . removedLabelIssues . length ) . toStrictEqual ( 0 ) ;
} ) ;
test ( 'a PR with an exempted milestone will not be marked as stale' , async ( ) = > {
expect . assertions ( 3 ) ;
const opts = { . . . DefaultProcessorOptions } ;
opts . exemptMilestones = 'Milestone1' ;
const TestIssueList : Issue [ ] = [
generateIssue (
opts ,
1 ,
'My first issue' ,
'2020-01-01T17:00:00Z' ,
'2020-01-01T17:00:00Z' ,
true ,
undefined ,
undefined ,
undefined ,
'Milestone1'
)
] ;
const processor = new IssueProcessor (
opts ,
async ( ) = > 'abot' ,
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num : number , dt : string ) = > [ ] ,
async ( issue : Issue , label : string ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toStrictEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toStrictEqual ( 0 ) ;
expect ( processor . removedLabelIssues . length ) . toStrictEqual ( 0 ) ;
} ) ;
test ( 'a PR with an exempted milestone will not be marked as stale (multi milestones with spaces)' , async ( ) = > {
expect . assertions ( 3 ) ;
const opts = { . . . DefaultProcessorOptions } ;
opts . exemptMilestones = 'Milestone1, Milestone2' ;
const TestIssueList : Issue [ ] = [
generateIssue (
opts ,
1 ,
'My first issue' ,
'2020-01-01T17:00:00Z' ,
'2020-01-01T17:00:00Z' ,
true ,
undefined ,
undefined ,
undefined ,
'Milestone2'
)
] ;
const processor = new IssueProcessor (
opts ,
async ( ) = > 'abot' ,
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num : number , dt : string ) = > [ ] ,
async ( issue : Issue , label : string ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toStrictEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toStrictEqual ( 0 ) ;
expect ( processor . removedLabelIssues . length ) . toStrictEqual ( 0 ) ;
} ) ;
test ( 'a PR with an exempted milestone will not be marked as stale (multi milestones without spaces)' , async ( ) = > {
expect . assertions ( 3 ) ;
const opts = { . . . DefaultProcessorOptions } ;
opts . exemptMilestones = 'Milestone1,Milestone2' ;
const TestIssueList : Issue [ ] = [
generateIssue (
opts ,
1 ,
'My first issue' ,
'2020-01-01T17:00:00Z' ,
'2020-01-01T17:00:00Z' ,
true ,
undefined ,
undefined ,
undefined ,
'Milestone2'
)
] ;
const processor = new IssueProcessor (
opts ,
async ( ) = > 'abot' ,
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num : number , dt : string ) = > [ ] ,
async ( issue : Issue , label : string ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toStrictEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toStrictEqual ( 0 ) ;
expect ( processor . removedLabelIssues . length ) . toStrictEqual ( 0 ) ;
} ) ;
test ( 'a PR with an exempted milestone but without an exempted issue milestone will not be marked as stale' , async ( ) = > {
expect . assertions ( 3 ) ;
const opts = { . . . DefaultProcessorOptions } ;
opts . exemptMilestones = 'Milestone1' ;
opts . exemptPrMilestones = '' ;
const TestIssueList : Issue [ ] = [
generateIssue (
opts ,
1 ,
'My first issue' ,
'2020-01-01T17:00:00Z' ,
'2020-01-01T17:00:00Z' ,
true ,
undefined ,
undefined ,
undefined ,
'Milestone1'
)
] ;
const processor = new IssueProcessor (
opts ,
async ( ) = > 'abot' ,
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num : number , dt : string ) = > [ ] ,
async ( issue : Issue , label : string ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toStrictEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toStrictEqual ( 0 ) ;
expect ( processor . removedLabelIssues . length ) . toStrictEqual ( 0 ) ;
} ) ;
test ( 'a PR with an exempted milestone but with another exempted issue milestone will be marked as stale' , async ( ) = > {
expect . assertions ( 3 ) ;
const opts = { . . . DefaultProcessorOptions } ;
opts . exemptMilestones = 'Milestone1' ;
opts . exemptPrMilestones = 'Milestone2' ;
const TestIssueList : Issue [ ] = [
generateIssue (
opts ,
1 ,
'My first issue' ,
'2020-01-01T17:00:00Z' ,
'2020-01-01T17:00:00Z' ,
true ,
undefined ,
undefined ,
undefined ,
'Milestone1'
)
] ;
const processor = new IssueProcessor (
opts ,
async ( ) = > 'abot' ,
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num : number , dt : string ) = > [ ] ,
async ( issue : Issue , label : string ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toStrictEqual ( 1 ) ;
expect ( processor . closedIssues . length ) . toStrictEqual ( 0 ) ;
expect ( processor . removedLabelIssues . length ) . toStrictEqual ( 0 ) ;
} ) ;
test ( 'a PR with an exempted milestone and with an exempted issue milestone will not be marked as stale' , async ( ) = > {
expect . assertions ( 3 ) ;
const opts = { . . . DefaultProcessorOptions } ;
opts . exemptMilestones = 'Milestone1' ;
opts . exemptPrMilestones = 'Milestone1' ;
const TestIssueList : Issue [ ] = [
generateIssue (
opts ,
1 ,
'My first issue' ,
'2020-01-01T17:00:00Z' ,
'2020-01-01T17:00:00Z' ,
true ,
undefined ,
undefined ,
undefined ,
'Milestone1'
)
] ;
const processor = new IssueProcessor (
opts ,
async ( ) = > 'abot' ,
async p = > ( p == 1 ? TestIssueList : [ ] ) ,
async ( num : number , dt : string ) = > [ ] ,
async ( issue : Issue , label : string ) = > new Date ( ) . toDateString ( )
) ;
// process our fake issue list
await processor . processIssues ( 1 ) ;
expect ( processor . staleIssues . length ) . toStrictEqual ( 0 ) ;
expect ( processor . closedIssues . length ) . toStrictEqual ( 0 ) ;
expect ( processor . removedLabelIssues . length ) . toStrictEqual ( 0 ) ;
} ) ;