- 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.
59 lines
1.3 KiB
TypeScript
59 lines
1.3 KiB
TypeScript
import {beforeEach, describe, expect, it} from '@jest/globals';
|
|
import {Issue} from '../classes/issue.js';
|
|
import {isPullRequest} from './is-pull-request.js';
|
|
|
|
describe('isPullRequest()', (): void => {
|
|
let issue: Issue;
|
|
|
|
describe('when the given issue has an undefined pull request', (): void => {
|
|
beforeEach((): void => {
|
|
issue = {
|
|
pull_request: undefined
|
|
} as Issue;
|
|
});
|
|
|
|
it('should return false', (): void => {
|
|
expect.assertions(1);
|
|
|
|
const result = isPullRequest(issue);
|
|
|
|
expect(result).toStrictEqual(false);
|
|
});
|
|
});
|
|
|
|
describe('when the given issue has a null pull request', (): void => {
|
|
beforeEach((): void => {
|
|
issue = {
|
|
pull_request: null
|
|
} as Issue;
|
|
});
|
|
|
|
it('should return false', (): void => {
|
|
expect.assertions(1);
|
|
|
|
const result = isPullRequest(issue);
|
|
|
|
expect(result).toStrictEqual(false);
|
|
});
|
|
});
|
|
|
|
describe.each([{}, true])(
|
|
'when the given issue has pull request',
|
|
(value): void => {
|
|
beforeEach((): void => {
|
|
issue = {
|
|
pull_request: value
|
|
} as Issue;
|
|
});
|
|
|
|
it('should return true', (): void => {
|
|
expect.assertions(1);
|
|
|
|
const result = isPullRequest(issue);
|
|
|
|
expect(result).toStrictEqual(true);
|
|
});
|
|
}
|
|
);
|
|
});
|