Files
stale/__tests__/functions/generate-issue.ts
Chiranjib Swain eaf9131fae refactor: update imports to use ES module syntax and improve test structure (#1350)
- 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.
2026-07-23 15:39:34 -05:00

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}} : {})
});
}