Skip to content

Commit

Permalink
chore: fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
fwuensche committed Sep 7, 2024
1 parent 157a420 commit 7852844
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
9 changes: 1 addition & 8 deletions src/git.test.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import { afterAll, beforeAll, describe, expect, it } from 'vitest'
import { describe, expect, it } from 'vitest'

import { guessProjectName } from './git.js'
import path from 'path'

const originalCwd = process.cwd()
const fakeProjectPath = path.join(originalCwd, 'test/fixtures/project-one')

describe('guessProjectName', () => {
beforeAll(() => process.chdir(fakeProjectPath)) // Change to `test/fixtures/project-one`
afterAll(() => process.chdir(originalCwd)) // Change back to the original working directory

it('returns an empty string if no pattern is recognized', async () => {
expect(guessProjectName(null)).toBe(null)
expect(guessProjectName('')).toBe(null)
Expand Down
20 changes: 9 additions & 11 deletions test/cherry.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,16 @@ const execAsync = promisify(exec)
describe('cherry', () => {
it('explains the usage', async () => {
try {
const { stderr } = await execAsync('node bin/cherry.js')

expect(stderr).toContain('Usage: cherry [options] [command]')
expect(stderr).toContain('init')
expect(stderr).toContain('run')
expect(stderr).toContain('push')
expect(stderr).toContain('diff')
expect(stderr).toContain('backfill')
expect(stderr).toContain('diff')
expect(stderr).toContain('help')
await execAsync('node bin/cherry.js')
} catch (error) {
expect(error).not.toBeNull()
expect(error.stderr).toContain('Usage: cherry [options] [command]')
expect(error.stderr).toContain('init')
expect(error.stderr).toContain('run')
expect(error.stderr).toContain('push')
expect(error.stderr).toContain('diff')
expect(error.stderr).toContain('backfill')
expect(error.stderr).toContain('diff')
expect(error.stderr).toContain('help')
}
})
})

0 comments on commit 7852844

Please sign in to comment.