/
cli.spec.js
63 lines (50 loc) 路 1.68 KB
/
cli.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
import updateNotifier from 'update-notifier'
import meow from 'meow'
import pkg from '../package.json'
import { options } from '../src/cli'
import commands from '../src/commands'
jest.mock('../src/commands')
describe('cli', () => {
it('should call updateNotifier', () => {
expect(updateNotifier).toHaveBeenCalledWith({ pkg })
expect(updateNotifier({ pkg }).notify).toHaveBeenCalledWith({
isGlobal: true
})
})
it('should match meow with cli information', () => {
meow.mock.calls[0][1].importMeta = 'import.meta.url'
expect(meow.mock.calls).toMatchSnapshot()
})
it('should call commit command on commit', () => {
options.commit('client')
expect(commands.commit).toHaveBeenCalledWith('client')
})
it('should call config command on config', () => {
options.config()
expect(commands.config).toHaveBeenCalledWith()
})
it('should call commit command on hook', () => {
options.hook('hook')
expect(commands.commit).toHaveBeenLastCalledWith('hook')
})
it('should call createHook command on init', () => {
options.init()
expect(commands.createHook).toHaveBeenCalledWith()
})
it('should call list command on list', () => {
options.list()
expect(commands.list).toHaveBeenCalledWith()
})
it('should call removeHook command on remove', () => {
options.remove()
expect(commands.removeHook).toHaveBeenCalledWith()
})
it('should call search command on search', () => {
options.search()
expect(commands.search).toHaveBeenCalledWith('testSearchQuery')
})
it('should call update command on update', () => {
options.update()
expect(commands.search).toHaveBeenCalledWith('testSearchQuery')
})
})