Skip to content

Commit

Permalink
start on some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftkey authored and outofambit committed Jul 25, 2019
1 parent 5000fc0 commit 664efe1
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions app/test/unit/git/worktree-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { setupEmptyRepository } from '../../helpers/repositories'
import { listWorktrees } from '../../../src/lib/git/worktree'

describe('git/worktree', () => {
describe('list', () => {
describe('for an unborn repository', () => {
it('returns one entry', async () => {
const repository = await setupEmptyRepository()
const result = await listWorktrees(repository)
expect(result).toHaveLength(1)
})

it('contains the head and path of the main repository', async () => {
const repository = await setupEmptyRepository()
const { path } = repository
const result = await listWorktrees(repository)
const first = result[0]
expect(first.head).toBe('0000000000000000000000000000000000000000')

// You might be wondering why this isn't a `.toBe` comparsion.
// Well, on macOS the path emitted by Git may start with a `/private`
// which is super-annoying and also different to what NodeJS returns,
// so we need to manage and reconcile these two cases
const endsWith = first.path.endsWith(path)
expect(endsWith).toBe(true)
})
})
})
})

0 comments on commit 664efe1

Please sign in to comment.