Update tests to correctly check state

This commit is contained in:
mviswanathsai 2024-03-05 19:03:19 +05:30
parent 834a5c7eb3
commit e0c4e25b76
No known key found for this signature in database
GPG Key ID: 87DE7BD64227C60A
2 changed files with 24 additions and 13 deletions

View File

@ -569,7 +569,6 @@ test('processing a stale issue containing a slash in the label will rotten it bu
...DefaultProcessorOptions,
staleIssueLabel: 'lifecycle/stale',
daysBeforeRotten: 0
};
const TestIssueList: Issue[] = [
generateIssue(
@ -604,7 +603,6 @@ test('processing a stale issue will rotten it but not close it when days-before-
...DefaultProcessorOptions,
daysBeforeRotten: -1,
daysBeforeIssueRotten: 30
};
const TestIssueList: Issue[] = [
generateIssue(
@ -667,7 +665,6 @@ test('processing a stale PR will rotten it but not close it', async () => {
expect(processor.closedIssues).toHaveLength(0);
});
test('processing a stale PR will rotten it it when days-before-pr-rotten override days-before-rotten', async () => {
const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions,
@ -815,7 +812,7 @@ test('processing a stale PR will rotten it even if configured not to mark as sta
...DefaultProcessorOptions,
daysBeforeStale: -1,
daysBeforeRotten: 0,
stalePrMessage: '',
stalePrMessage: ''
};
const TestIssueList: Issue[] = [
generateIssue(
@ -850,7 +847,7 @@ test('processing a stale PR will close it even if configured not to mark as stal
...DefaultProcessorOptions,
daysBeforeStale: -1,
stalePrMessage: '',
daysBeforeRotten: -1,
daysBeforeRotten: -1
};
const TestIssueList: Issue[] = [
generateIssue(
@ -1410,7 +1407,10 @@ test('stale issues should not be closed if days is set to -1', async () => {
});
test('stale label should be removed if a comment was added to a stale issue', async () => {
const opts = {...DefaultProcessorOptions, removeStaleWhenUpdated: true, daysBeforeRotten: 0,
const opts = {
...DefaultProcessorOptions,
removeStaleWhenUpdated: true,
daysBeforeRotten: 0
};
const TestIssueList: Issue[] = [
generateIssue(
@ -1539,7 +1539,10 @@ test('when the option "labelsToRemoveWhenStale" is set, the labels should be rem
});
test('stale label should not be removed if a comment was added by the bot (and the issue should be rotten)', async () => {
const opts = {...DefaultProcessorOptions, removeStaleWhenUpdated: true, daysBeforeRotten: 0,
const opts = {
...DefaultProcessorOptions,
removeStaleWhenUpdated: true,
daysBeforeRotten: 0
};
github.context.actor = 'abot';
const TestIssueList: Issue[] = [
@ -1895,7 +1898,11 @@ test('send stale message on prs when stale-pr-message is not empty', async () =>
});
test('git branch is deleted when option is enabled and days before rotten is set to -1', async () => {
const opts = {...DefaultProcessorOptions, deleteBranch: true, daysBeforeRotten: -1,};
const opts = {
...DefaultProcessorOptions,
deleteBranch: true,
daysBeforeRotten: -1
};
const isPullRequest = true;
const TestIssueList: Issue[] = [
generateIssue(
@ -1926,7 +1933,11 @@ test('git branch is deleted when option is enabled and days before rotten is set
});
test('git branch is not deleted when issue is not pull request and days before rotten is set to -1', async () => {
const opts = {...DefaultProcessorOptions, deleteBranch: true, daysBeforeRotten: -1,};
const opts = {
...DefaultProcessorOptions,
deleteBranch: true,
daysBeforeRotten: -1
};
const isPullRequest = false;
const TestIssueList: Issue[] = [
generateIssue(
@ -2816,7 +2827,7 @@ test('processing a pull request to be stale with the "stalePrMessage" option set
stalePrMessage: 'This PR is stale',
daysBeforeStale: 10,
daysBeforePrStale: 1,
daysBeforeRotten: -1,
daysBeforeRotten: -1
};
const issueDate = new Date();
issueDate.setDate(issueDate.getDate() - 2);

View File

@ -175,7 +175,7 @@ describe('state', (): void => {
it('state should be reset if all issues are proceeded', async () => {
const opts: IIssuesProcessorOptions = {
...DefaultProcessorOptions,
daysBeforeClose: 0,
daysBeforeClose: 0
};
const testIssue1 = generateIssue(
opts,
@ -202,7 +202,7 @@ describe('state', (): void => {
await processor.processIssues(1);
// make sure all issues are proceeded
expect(infoSpy.mock.calls[71][0]).toContain(
expect(infoSpy.mock.calls[77][0]).toContain(
'No more issues found to process. Exiting...'
);