Skip to content

Commit

Permalink
test: mock resolveGitDir to fix runAll tests
Browse files Browse the repository at this point in the history
  • Loading branch information
iiroj authored and okonet committed Aug 17, 2019
1 parent 82b5182 commit c9424ad
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions test/runAll.spec.js
@@ -1,31 +1,35 @@
import makeConsoleMock from 'consolemock'
import execa from 'execa'
import normalize from 'normalize-path'

import resolveGitDir from '../src/resolveGitDir'
import getStagedFiles from '../src/getStagedFiles'
import runAll from '../src/runAll'
import { hasPartiallyStagedFiles, gitStashSave, gitStashPop, updateStash } from '../src/gitWorkflow'

jest.mock('../src/resolveGitDir')
jest.mock('../src/getStagedFiles')
jest.mock('../src/gitWorkflow')

resolveGitDir.mockImplementation(async () => normalize(process.cwd()))
getStagedFiles.mockImplementation(async () => [])

const globalConsoleTemp = global.console
const globalConsoleTemp = console

describe('runAll', () => {
beforeAll(() => {
global.console = makeConsoleMock()
console = makeConsoleMock()
})

afterEach(() => {
global.console.clearHistory()
console.clearHistory()
gitStashSave.mockClear()
gitStashPop.mockClear()
updateStash.mockClear()
})

afterAll(() => {
global.console = globalConsoleTemp
console = globalConsoleTemp
})

it('should not throw when a valid config is provided', () => {
Expand Down

0 comments on commit c9424ad

Please sign in to comment.