mirror of
https://github.com/game-ci/unity-builder.git
synced 2026-06-02 23:06:15 -07:00
* fix: misalignments in dev lifecycle * fix: dist no longer added to staged * fix: misalignments in dev lifecycle * chore: multi-platform hooks and tests * chore: multi-platform hooks and tests * chore: add intention for colors * chore: update lint-staged to fix color * chore: update dist files * feat: move to lefthook (remove husky and lint-staged) * feat: move to lefthook (remove husky and lint-staged) * fix: test aftereach * fix: test aftereach * fix: early restore call * feat: jest fails if something gets logged to console * chore: add todos of misplaced code * chore: update dist files * chore: move jest file
47 lines
1.6 KiB
TypeScript
47 lines
1.6 KiB
TypeScript
import * as core from '@actions/core';
|
|
import * as exec from '@actions/exec';
|
|
import System from './system';
|
|
|
|
jest.spyOn(core, 'debug').mockImplementation(() => {});
|
|
const info = jest.spyOn(core, 'info').mockImplementation(() => {});
|
|
jest.spyOn(core, 'warning').mockImplementation(() => {});
|
|
jest.spyOn(core, 'error').mockImplementation(() => {});
|
|
const execSpy = jest.spyOn(exec, 'exec').mockImplementation(async () => 0);
|
|
|
|
afterEach(() => jest.clearAllMocks());
|
|
|
|
describe('System', () => {
|
|
describe('run', () => {
|
|
describe('units', () => {
|
|
it('passes the command to command line', async () => {
|
|
await expect(System.run('echo test')).resolves.not.toBeNull();
|
|
await expect(execSpy).toHaveBeenLastCalledWith('echo test', expect.anything(), expect.anything());
|
|
});
|
|
|
|
it('throws on when error code is not 0', async () => {
|
|
execSpy.mockImplementationOnce(async () => 1);
|
|
await expect(System.run('false')).rejects.toThrowError();
|
|
});
|
|
|
|
it('throws when no command is given', async () => {
|
|
await expect(System.run('')).rejects.toThrowError();
|
|
});
|
|
|
|
it('throws when command consists only of spaces', async () => {
|
|
await expect(System.run(' \t\n')).rejects.toThrowError();
|
|
});
|
|
|
|
it('outputs info', async () => {
|
|
execSpy.mockImplementationOnce(async (input, _, options) => {
|
|
options?.listeners?.stdout?.(Buffer.from(input, 'utf8'));
|
|
return 0;
|
|
});
|
|
|
|
await expect(System.run('foo-bar')).resolves.not.toBeNull();
|
|
expect(info).toHaveBeenCalledTimes(1);
|
|
expect(info).toHaveBeenLastCalledWith('foo-bar');
|
|
});
|
|
});
|
|
});
|
|
});
|