Update tests to correctly check state
This commit is contained in:
parent
834a5c7eb3
commit
e0c4e25b76
|
@ -569,7 +569,6 @@ test('processing a stale issue containing a slash in the label will rotten it bu
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
staleIssueLabel: 'lifecycle/stale',
|
staleIssueLabel: 'lifecycle/stale',
|
||||||
daysBeforeRotten: 0
|
daysBeforeRotten: 0
|
||||||
|
|
||||||
};
|
};
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(
|
generateIssue(
|
||||||
|
@ -604,7 +603,6 @@ test('processing a stale issue will rotten it but not close it when days-before-
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
daysBeforeRotten: -1,
|
daysBeforeRotten: -1,
|
||||||
daysBeforeIssueRotten: 30
|
daysBeforeIssueRotten: 30
|
||||||
|
|
||||||
};
|
};
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(
|
generateIssue(
|
||||||
|
@ -667,7 +665,6 @@ test('processing a stale PR will rotten it but not close it', async () => {
|
||||||
expect(processor.closedIssues).toHaveLength(0);
|
expect(processor.closedIssues).toHaveLength(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
test('processing a stale PR will rotten it it when days-before-pr-rotten override days-before-rotten', async () => {
|
test('processing a stale PR will rotten it it when days-before-pr-rotten override days-before-rotten', async () => {
|
||||||
const opts: IIssuesProcessorOptions = {
|
const opts: IIssuesProcessorOptions = {
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
|
@ -815,7 +812,7 @@ test('processing a stale PR will rotten it even if configured not to mark as sta
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
daysBeforeStale: -1,
|
daysBeforeStale: -1,
|
||||||
daysBeforeRotten: 0,
|
daysBeforeRotten: 0,
|
||||||
stalePrMessage: '',
|
stalePrMessage: ''
|
||||||
};
|
};
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(
|
generateIssue(
|
||||||
|
@ -850,7 +847,7 @@ test('processing a stale PR will close it even if configured not to mark as stal
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
daysBeforeStale: -1,
|
daysBeforeStale: -1,
|
||||||
stalePrMessage: '',
|
stalePrMessage: '',
|
||||||
daysBeforeRotten: -1,
|
daysBeforeRotten: -1
|
||||||
};
|
};
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(
|
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 () => {
|
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[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(
|
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 () => {
|
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';
|
github.context.actor = 'abot';
|
||||||
const TestIssueList: Issue[] = [
|
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 () => {
|
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 isPullRequest = true;
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(
|
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 () => {
|
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 isPullRequest = false;
|
||||||
const TestIssueList: Issue[] = [
|
const TestIssueList: Issue[] = [
|
||||||
generateIssue(
|
generateIssue(
|
||||||
|
@ -2816,7 +2827,7 @@ test('processing a pull request to be stale with the "stalePrMessage" option set
|
||||||
stalePrMessage: 'This PR is stale',
|
stalePrMessage: 'This PR is stale',
|
||||||
daysBeforeStale: 10,
|
daysBeforeStale: 10,
|
||||||
daysBeforePrStale: 1,
|
daysBeforePrStale: 1,
|
||||||
daysBeforeRotten: -1,
|
daysBeforeRotten: -1
|
||||||
};
|
};
|
||||||
const issueDate = new Date();
|
const issueDate = new Date();
|
||||||
issueDate.setDate(issueDate.getDate() - 2);
|
issueDate.setDate(issueDate.getDate() - 2);
|
||||||
|
|
|
@ -175,7 +175,7 @@ describe('state', (): void => {
|
||||||
it('state should be reset if all issues are proceeded', async () => {
|
it('state should be reset if all issues are proceeded', async () => {
|
||||||
const opts: IIssuesProcessorOptions = {
|
const opts: IIssuesProcessorOptions = {
|
||||||
...DefaultProcessorOptions,
|
...DefaultProcessorOptions,
|
||||||
daysBeforeClose: 0,
|
daysBeforeClose: 0
|
||||||
};
|
};
|
||||||
const testIssue1 = generateIssue(
|
const testIssue1 = generateIssue(
|
||||||
opts,
|
opts,
|
||||||
|
@ -202,7 +202,7 @@ describe('state', (): void => {
|
||||||
|
|
||||||
await processor.processIssues(1);
|
await processor.processIssues(1);
|
||||||
// make sure all issues are proceeded
|
// 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...'
|
'No more issues found to process. Exiting...'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue