-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathgitRunner.test.ts
More file actions
32 lines (26 loc) · 892 Bytes
/
Copy pathgitRunner.test.ts
File metadata and controls
32 lines (26 loc) · 892 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// @ts-nocheck
import { afterEach, describe, expect, it, spyOn } from 'bun:test';
import * as childProcess from 'child_process';
import { defaultGitRunner } from './gitHandlers.js';
describe('defaultGitRunner', () => {
let spawnSyncSpy: ReturnType<typeof spyOn>;
afterEach(() => {
spawnSyncSpy?.mockRestore();
});
it('captures successful stderr instead of inheriting it', () => {
spawnSyncSpy = spyOn(childProcess, 'spawnSync').mockReturnValue({
status: 0,
stdout: 'ok\n',
stderr: 'warning: LF will be replaced by CRLF\n',
} as any);
const result = defaultGitRunner(['status'], process.cwd());
expect(result).toEqual({
ok: true,
stdout: 'ok\n',
stderr: 'warning: LF will be replaced by CRLF\n',
});
expect(spawnSyncSpy.mock.calls[0]?.[2]).toMatchObject({
stdio: ['ignore', 'pipe', 'pipe'],
});
});
});