/
vault.spec.js
68 lines (59 loc) 路 1.97 KB
/
vault.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import configurationVault from '@utils/configurationVault'
import getConfiguration from '@utils/configurationVault/getConfiguration'
import {
CONFIG,
EMOJI_COMMIT_FORMATS
} from '@constants/configuration'
jest.mock('@utils/configurationVault/getConfiguration', () => jest.fn().mockReturnValue({
set: jest.fn(),
get: jest.fn()
}))
describe('index > vault', () => {
describe('setter and getters', () => {
it('should set and return value for autoAdd', () => {
configurationVault.setAutoAdd(true)
configurationVault.getAutoAdd()
expect(getConfiguration().set).toHaveBeenCalledWith(
CONFIG.AUTO_ADD,
true
)
expect(getConfiguration().get).toHaveBeenCalledWith(
CONFIG.AUTO_ADD,
)
})
it('should set and return value for emojiFormat', () => {
configurationVault.setEmojiFormat('emoji')
configurationVault.getEmojiFormat()
expect(getConfiguration().set).toHaveBeenCalledWith(
CONFIG.EMOJI_FORMAT,
EMOJI_COMMIT_FORMATS.EMOJI
)
expect(getConfiguration().get).toHaveBeenCalledWith(
CONFIG.EMOJI_FORMAT
)
})
it('should set and return value for scopePrompt', () => {
configurationVault.setScopePrompt(true)
configurationVault.getScopePrompt()
expect(getConfiguration().set).toHaveBeenCalledWith(
CONFIG.SCOPE_PROMPT,
true
)
expect(getConfiguration().get).toHaveBeenCalledWith(
CONFIG.SCOPE_PROMPT
)
})
it('should set and return value for gitmojisUrl', () => {
const testGitmojisUrl = 'https://raw.githubusercontent.com/carloscuesta/gitmoji/master/src/data/gitmojis.json'
configurationVault.setGitmojisUrl(testGitmojisUrl)
configurationVault.getGitmojisUrl()
expect(getConfiguration().set).toHaveBeenCalledWith(
CONFIG.GITMOJIS_URL,
testGitmojisUrl
)
expect(getConfiguration().get).toHaveBeenCalledWith(
CONFIG.GITMOJIS_URL
)
})
})
})