stale/__tests__/functions/generate-issue.ts
Geoffrey Testelin 1cdda06bb3
feat(options): add new option ignore-updates to stale even with activity (#540)
* chore(assignees): add logs

* docs(readme): use the override syntax to simplify the reading

* docs(readme): add missing default options

* docs(readme): add 3 new options to ignore activity before stale

* chore(action): add 3 new options

* fix(removeStaleWhenUpdated): use the value of the action config as expected

Fixes #451

* chore(main): add 3 new options

* feat(ignore): add new class to ignore all activities before stale

* feat(option): add new options to ignore all activities before stale

* chore(index): update index file

* docs(readme): fix typo

* docs(readme): add missing empty row

* chore(rebase): fix logger issues due to rebase

* chore: aplly changes due to rebase

* refactor(naming): change the name of the options as suggested

* chore(logs): reverse the logs as well

* docs(readme): format the table of options

* refactor(naming): rename the the options

* style(rename): rename more updates wording to activities

* build(ci): run the test step as expected for a CI

instead of using a real linter with auto fix and the tests verbose as fuck

* chore: handle breaking changes due to new changes

* refactor(naming): rename and reverse the options

* style(tests): use plural for some describe

* docs(days-before-stale): list the new option

* chore(index): update index file

* chore: keep static methods on top

* chore(logs): remove useless log
2021-09-17 09:54:38 -04:00

43 lines
1.1 KiB
TypeScript

import {Issue} from '../../src/classes/issue';
import {IUserAssignee} from '../../src/interfaces/assignee';
import {IIssuesProcessorOptions} from '../../src/interfaces/issues-processor-options';
import {IsoDateString} from '../../src/types/iso-date-string';
export function generateIssue(
options: IIssuesProcessorOptions,
id: number,
title: string,
updatedAt: IsoDateString,
createdAt: IsoDateString = updatedAt,
isPullRequest = false,
labels: string[] = [],
isClosed = false,
isLocked = false,
milestone: string | undefined = undefined,
assignees: string[] = []
): Issue {
return new Issue(options, {
number: id,
labels: labels.map(l => {
return {name: l};
}),
title,
created_at: createdAt,
updated_at: updatedAt,
pull_request: isPullRequest ? {} : null,
state: isClosed ? 'closed' : 'open',
locked: isLocked,
milestone: milestone
? {
title: milestone
}
: undefined,
assignees: assignees.map((assignee: Readonly<string>): IUserAssignee => {
return {
login: assignee,
type: 'User'
};
})
});
}