@@ -1422,11 +1422,11 @@ test('stale issues should not be closed until after the closed number of days (l
14221422 expect ( processor . staleIssues ) . toHaveLength ( 1 ) ;
14231423} ) ;
14241424
1425- test ( 'skips stale message on issues when skip- stale-issue-message is set ' , async ( ) => {
1425+ test ( 'skips stale message on issues when stale-issue-message is empty ' , async ( ) => {
14261426 const opts = { ...DefaultProcessorOptions } ;
14271427 opts . daysBeforeStale = 5 ; // stale after 5 days
14281428 opts . daysBeforeClose = 20 ; // closes after 25 days
1429- opts . skipStaleIssueMessage = true ;
1429+ opts . staleIssueMessage = '' ;
14301430 const lastUpdate = new Date ( ) ;
14311431 lastUpdate . setDate ( lastUpdate . getDate ( ) - 10 ) ;
14321432 const TestIssueList : Issue [ ] = [
@@ -1467,11 +1467,11 @@ test('skips stale message on issues when skip-stale-issue-message is set', async
14671467 ) ;
14681468} ) ;
14691469
1470- test ( 'skips stale message on prs when skip- stale-pr -message is set ' , async ( ) => {
1470+ test ( 'send stale message on issues when stale-issue -message is not empty ' , async ( ) => {
14711471 const opts = { ...DefaultProcessorOptions } ;
14721472 opts . daysBeforeStale = 5 ; // stale after 5 days
14731473 opts . daysBeforeClose = 20 ; // closes after 25 days
1474- opts . skipStalePrMessage = true ;
1474+ opts . staleIssueMessage = 'dummy issue message' ;
14751475 const lastUpdate = new Date ( ) ;
14761476 lastUpdate . setDate ( lastUpdate . getDate ( ) - 10 ) ;
14771477 const TestIssueList : Issue [ ] = [
@@ -1481,7 +1481,7 @@ test('skips stale message on prs when skip-stale-pr-message is set', async () =>
14811481 'An issue that should be marked stale but not closed' ,
14821482 lastUpdate . toString ( ) ,
14831483 lastUpdate . toString ( ) ,
1484- true
1484+ false
14851485 )
14861486 ] ;
14871487 const processor = new IssuesProcessorMock (
@@ -1505,19 +1505,18 @@ test('skips stale message on prs when skip-stale-pr-message is set', async () =>
15051505 // comment should not be created
15061506 expect ( markSpy ) . toHaveBeenCalledWith (
15071507 TestIssueList [ 0 ] ,
1508- opts . stalePrMessage ,
1509- opts . stalePrLabel ,
1508+ opts . staleIssueMessage ,
1509+ opts . staleIssueLabel ,
15101510 // this option is skipMessage
1511- true
1511+ false
15121512 ) ;
15131513} ) ;
15141514
1515- test ( 'not providing state takes precedence over skipStaleIssueMessage ' , async ( ) => {
1515+ test ( 'skips stale message on prs when stale-pr-message is empty ' , async ( ) => {
15161516 const opts = { ...DefaultProcessorOptions } ;
15171517 opts . daysBeforeStale = 5 ; // stale after 5 days
15181518 opts . daysBeforeClose = 20 ; // closes after 25 days
1519- opts . skipStalePrMessage = true ;
1520- opts . staleIssueMessage = '' ;
1519+ opts . stalePrMessage = '' ;
15211520 const lastUpdate = new Date ( ) ;
15221521 lastUpdate . setDate ( lastUpdate . getDate ( ) - 10 ) ;
15231522 const TestIssueList : Issue [ ] = [
@@ -1527,7 +1526,7 @@ test('not providing state takes precedence over skipStaleIssueMessage', async ()
15271526 'An issue that should be marked stale but not closed' ,
15281527 lastUpdate . toString ( ) ,
15291528 lastUpdate . toString ( ) ,
1530- false
1529+ true
15311530 )
15321531 ] ;
15331532 const processor = new IssuesProcessorMock (
@@ -1538,20 +1537,31 @@ test('not providing state takes precedence over skipStaleIssueMessage', async ()
15381537 async ( ) => new Date ( ) . toDateString ( )
15391538 ) ;
15401539
1540+ // for sake of testing, mocking private function
1541+ const markSpy = jest . spyOn ( processor as any , '_markStale' ) ;
1542+
15411543 await processor . processIssues ( 1 ) ;
15421544
15431545 // issue should be staled
15441546 expect ( processor . closedIssues ) . toHaveLength ( 0 ) ;
15451547 expect ( processor . removedLabelIssues ) . toHaveLength ( 0 ) ;
1546- expect ( processor . staleIssues ) . toHaveLength ( 0 ) ;
1548+ expect ( processor . staleIssues ) . toHaveLength ( 1 ) ;
1549+
1550+ // comment should not be created
1551+ expect ( markSpy ) . toHaveBeenCalledWith (
1552+ TestIssueList [ 0 ] ,
1553+ opts . stalePrMessage ,
1554+ opts . stalePrLabel ,
1555+ // this option is skipMessage
1556+ true
1557+ ) ;
15471558} ) ;
15481559
1549- test ( 'not providing stalePrMessage takes precedence over skipStalePrMessage ' , async ( ) => {
1560+ test ( 'send stale message on prs when stale-pr-message is not empty ' , async ( ) => {
15501561 const opts = { ...DefaultProcessorOptions } ;
15511562 opts . daysBeforeStale = 5 ; // stale after 5 days
15521563 opts . daysBeforeClose = 20 ; // closes after 25 days
1553- opts . skipStalePrMessage = true ;
1554- opts . stalePrMessage = '' ;
1564+ opts . stalePrMessage = 'dummy pr message' ;
15551565 const lastUpdate = new Date ( ) ;
15561566 lastUpdate . setDate ( lastUpdate . getDate ( ) - 10 ) ;
15571567 const TestIssueList : Issue [ ] = [
@@ -1572,12 +1582,24 @@ test('not providing stalePrMessage takes precedence over skipStalePrMessage', as
15721582 async ( ) => new Date ( ) . toDateString ( )
15731583 ) ;
15741584
1585+ // for sake of testing, mocking private function
1586+ const markSpy = jest . spyOn ( processor as any , '_markStale' ) ;
1587+
15751588 await processor . processIssues ( 1 ) ;
15761589
15771590 // issue should be staled
15781591 expect ( processor . closedIssues ) . toHaveLength ( 0 ) ;
15791592 expect ( processor . removedLabelIssues ) . toHaveLength ( 0 ) ;
1580- expect ( processor . staleIssues ) . toHaveLength ( 0 ) ;
1593+ expect ( processor . staleIssues ) . toHaveLength ( 1 ) ;
1594+
1595+ // comment should not be created
1596+ expect ( markSpy ) . toHaveBeenCalledWith (
1597+ TestIssueList [ 0 ] ,
1598+ opts . stalePrMessage ,
1599+ opts . stalePrLabel ,
1600+ // this option is skipMessage
1601+ false
1602+ ) ;
15811603} ) ;
15821604
15831605test ( 'git branch is deleted when option is enabled' , async ( ) => {
0 commit comments