/
state.spec.js
40 lines (35 loc) · 1.44 KB
/
state.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import {
applyModificationsSkipped,
cleanupSkipped,
restoreOriginalStateSkipped,
restoreUnstagedChangesSkipped
} from '../lib/state'
import { GitError, RestoreOriginalStateError } from '../lib/symbols'
describe('applyModificationsSkipped', () => {
it('should return false when backup is disabled', () => {
const result = applyModificationsSkipped({ shouldBackup: false })
expect(result).toEqual(false)
})
it('should return error message when there is an unkown git error', () => {
const result = applyModificationsSkipped({ shouldBackup: true, errors: new Set([GitError]) })
expect(typeof result === 'string').toEqual(true)
})
})
describe('restoreUnstagedChangesSkipped', () => {
it('should return error message when there is an unkown git error', () => {
const result = restoreUnstagedChangesSkipped({ errors: new Set([GitError]) })
expect(typeof result === 'string').toEqual(true)
})
})
describe('restoreOriginalStateSkipped', () => {
it('should return error message when there is an unkown git error', () => {
const result = restoreOriginalStateSkipped({ errors: new Set([GitError]) })
expect(typeof result === 'string').toEqual(true)
})
})
describe('shouldSkipCleanup', () => {
it('should return error message when reverting to original state fails', () => {
const result = cleanupSkipped({ errors: new Set([RestoreOriginalStateError]) })
expect(typeof result === 'string').toEqual(true)
})
})