stale/__tests__/classes/issues-processor-mock.ts

42 lines
1.2 KiB
TypeScript
Raw Normal View History

import {Issue} from '../../src/classes/issue';
import {IssuesProcessor} from '../../src/classes/issues-processor';
import {IComment} from '../../src/interfaces/comment';
import {IIssuesProcessorOptions} from '../../src/interfaces/issues-processor-options';
import {IPullRequest} from '../../src/interfaces/pull-request';
2023-06-22 19:20:34 +08:00
import {IState} from '../../src/interfaces/state';
export class IssuesProcessorMock extends IssuesProcessor {
constructor(
options: IIssuesProcessorOptions,
2023-06-22 19:20:34 +08:00
state: IState,
getIssues?: (page: number) => Promise<Issue[]>,
listIssueComments?: (
issue: Issue,
sinceDate: string
) => Promise<IComment[]>,
getLabelCreationDate?: (
issue: Issue,
label: string
) => Promise<string | undefined>,
getPullRequest?: (issue: Issue) => Promise<IPullRequest | undefined | void>
) {
2023-06-22 19:20:34 +08:00
super(options, state);
if (getIssues) {
this.getIssues = getIssues;
}
if (listIssueComments) {
this.listIssueComments = listIssueComments;
}
if (getLabelCreationDate) {
this.getLabelCreationDate = getLabelCreationDate;
}
if (getPullRequest) {
this.getPullRequest = getPullRequest;
}
}
}