/
execGit.spec.js
37 lines (32 loc) · 1.01 KB
/
execGit.spec.js
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
33
34
35
36
37
import path from 'node:path'
import { getMockExeca } from './__utils__/getMockExeca.js'
const { execa } = await getMockExeca()
const { execGit, GIT_GLOBAL_OPTIONS } = await import('../../lib/execGit.js')
test('GIT_GLOBAL_OPTIONS', () => {
expect(GIT_GLOBAL_OPTIONS).toMatchInlineSnapshot(`
[
"-c",
"submodule.recurse=false",
]
`)
})
describe('execGit', () => {
it('should execute git in process.cwd if working copy is not specified', async () => {
const cwd = process.cwd()
await execGit(['init', 'param'])
expect(execa).toHaveBeenCalledWith('git', [...GIT_GLOBAL_OPTIONS, 'init', 'param'], {
all: true,
cwd,
stdin: 'ignore',
})
})
it('should execute git in a given working copy', async () => {
const cwd = path.join(process.cwd(), 'test', '__fixtures__')
await execGit(['init', 'param'], { cwd })
expect(execa).toHaveBeenCalledWith('git', [...GIT_GLOBAL_OPTIONS, 'init', 'param'], {
all: true,
cwd,
stdin: 'ignore',
})
})
})