mirror of
https://github.com/actions/stale.git
synced 2026-08-21 16:13:08 +01:00
- Changed import statements across multiple files to use the .js extension for ES module compatibility. - Refactored test files to utilize jest's unstable_mockModule for mocking core actions. - Removed unnecessary spy instances in tests, replacing them with direct mocked function calls. - Updated TypeScript configuration to target ES2022 and use NodeNext module resolution. - Removed the tsconfig.spec.json file and adjusted the main tsconfig.json to exclude test files.
47 lines
1.2 KiB
TypeScript
47 lines
1.2 KiB
TypeScript
import {Issue} from '../../src/classes/issue.js';
|
|
import {IUserAssignee} from '../../src/interfaces/assignee.js';
|
|
import {IIssuesProcessorOptions} from '../../src/interfaces/issues-processor-options.js';
|
|
import {IsoDateString} from '../../src/types/iso-date-string.js';
|
|
|
|
export function generateIssue(
|
|
options: IIssuesProcessorOptions,
|
|
id: number,
|
|
title: string,
|
|
updatedAt: IsoDateString,
|
|
createdAt: IsoDateString = updatedAt,
|
|
draft = false,
|
|
isPullRequest = false,
|
|
labels: string[] = [],
|
|
isClosed = false,
|
|
isLocked = false,
|
|
milestone: string | undefined = undefined,
|
|
assignees: string[] = [],
|
|
issue_type?: string
|
|
): Issue {
|
|
return new Issue(options, {
|
|
number: id,
|
|
labels: labels.map(l => {
|
|
return {name: l};
|
|
}),
|
|
title,
|
|
created_at: createdAt,
|
|
updated_at: updatedAt,
|
|
draft: draft,
|
|
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'
|
|
};
|
|
}),
|
|
...(issue_type ? {type: {name: issue_type}} : {})
|
|
});
|
|
}
|