1
0
Fork 0
mirror of https://code.forgejo.org/actions/git-backporting synced 2025-03-15 06:36:59 +01:00
git-backporting/test/support/utils.ts

27 lines
741 B
TypeScript
Raw Normal View History

import * as core from "@actions/core";
export const addProcessArgs = (args: string[]) => {
process.argv = [...process.argv, ...args];
};
export const resetProcessArgs = () => {
process.argv = ["node", "backporting"];
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const spyGetInput = (obj: any) => {
const mock = jest.spyOn(core, "getInput");
mock.mockImplementation((name: string) : string => {
return obj[name] ?? "";
});
};
/**
* Check array equality performing sort on both sides.
* DO NOT USE this if ordering matters
* @param actual
* @param expected
*/
export const expectArrayEqual = (actual: unknown[], expected: unknown[]) => {
expect(actual.sort()).toEqual(expected.sort());
};