forked from prisma/prisma
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDbCommand.test.ts
32 lines (25 loc) · 982 Bytes
/
DbCommand.test.ts
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
import { DbCommand } from '../commands/DbCommand'
it('no params should return help', async () => {
const commandInstance = DbCommand.new({})
const spy = jest.spyOn(commandInstance, 'help').mockImplementation(() => 'Help Me')
await commandInstance.parse([])
expect(spy).toHaveBeenCalledTimes(1)
spy.mockRestore()
})
it('wrong flag', async () => {
const commandInstance = DbCommand.new({})
const spy = jest.spyOn(commandInstance, 'help').mockImplementation(() => 'Help Me')
await commandInstance.parse(['--something'])
expect(spy).toHaveBeenCalledTimes(1)
spy.mockRestore()
})
it('help flag', async () => {
const commandInstance = DbCommand.new({})
const spy = jest.spyOn(commandInstance, 'help').mockImplementation(() => 'Help Me')
await commandInstance.parse(['--help'])
expect(spy).toHaveBeenCalledTimes(1)
spy.mockRestore()
})
it('unknown command', async () => {
await expect(DbCommand.new({}).parse(['doesnotexist'])).resolves.toThrow()
})