mirror of
https://github.com/hanzoai/lint-staged.git
synced 2026-10-30 19:37:36 +00:00
33 lines
886 B
JavaScript
33 lines
886 B
JavaScript
import path from 'node:path'
|
|
|
|
import { exec } from 'tinyexec'
|
|
import { beforeEach, describe, it, test, vi } from 'vitest'
|
|
|
|
import { execGit, GIT_GLOBAL_OPTIONS } from '../../lib/execGit.js'
|
|
|
|
vi.mock('tinyexec', () => ({
|
|
exec: vi.fn().mockImplementation(async () => ({ stdout: 'test' })),
|
|
}))
|
|
|
|
test('GIT_GLOBAL_OPTIONS', ({ expect }) => {
|
|
expect(GIT_GLOBAL_OPTIONS).toEqual(['-c', 'submodule.recurse=false'])
|
|
})
|
|
|
|
describe('execGit', () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks()
|
|
})
|
|
|
|
it('should execute git in a given working copy', async ({ expect }) => {
|
|
const cwd = path.join(process.cwd(), 'test', '__fixtures__')
|
|
const output = await execGit(['init', 'param'], { cwd })
|
|
expect(exec).toHaveBeenCalledExactlyOnceWith('git', [...GIT_GLOBAL_OPTIONS, 'init', 'param'], {
|
|
nodeOptions: {
|
|
cwd,
|
|
},
|
|
})
|
|
|
|
expect(output).toBe('test')
|
|
})
|
|
})
|