Skip to content

Commit

Permalink
Update test
Browse files Browse the repository at this point in the history
  • Loading branch information
usmanyunusov committed Apr 15, 2022
1 parent 1c9fe98 commit 42cab85
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions test/git.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { equal, is } from 'uvu/assert'
import { join } from 'path'
import { join, resolve } from 'path'
import { test } from 'uvu'
import fs from 'fs-extra'

Expand Down Expand Up @@ -50,12 +50,15 @@ test('should return "null" when run error', async () => {

test('should return path when git dir is found', async () => {
let git = createGit(cwd)
git.exec = async () => 'test'

let git_paths = await git.getGitPaths()

is(git_paths.root, 'test')
is(git_paths.dot, process.platform === 'win32' ? 'test\\.git' : 'test/.git')
is(git_paths.root, fixture('simple/git-test'))
is(
git_paths.dot,
process.platform === 'win32'
? fixture('simple/git-test') + '\\.git'
: fixture('simple/git-test') + '/.git'
)
})

test('should create patch to file', async () => {
Expand Down Expand Up @@ -228,4 +231,17 @@ test('should get unstaged files correctly', async () => {
})
})

test('should handle git worktrees', async () => {
let git = createGit(cwd)
let work_tree_dir = resolve(cwd, 'worktree')

await execGit(['branch', 'test'])
await execGit(['worktree', 'add', work_tree_dir, 'test'])

equal(await git.getGitPaths({ cwd: work_tree_dir }), {
root: fixture('simple/git-test/worktree'),
dot: fixture('simple/git-test/.git/worktrees/worktree'),
})
})

test.run()

0 comments on commit 42cab85

Please sign in to comment.