forked from prisma/prisma
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDbCommand.test.ts
More file actions
34 lines (27 loc) · 1.21 KB
/
DbCommand.test.ts
File metadata and controls
34 lines (27 loc) · 1.21 KB
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
import { DbCommand } from '../commands/DbCommand'
import { createDefaultTestContext } from './__helpers__/context'
const ctx = createDefaultTestContext()
it('no params should return help', async () => {
const commandInstance = DbCommand.new({})
const spy = jest.spyOn(commandInstance, 'help').mockImplementation(() => 'Help Me')
await commandInstance.parse([], await ctx.config(), ctx.configDir())
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'], await ctx.config(), ctx.configDir())
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'], await ctx.config(), ctx.configDir())
expect(spy).toHaveBeenCalledTimes(1)
spy.mockRestore()
})
it('unknown command', async () => {
await expect(DbCommand.new({}).parse(['doesnotexist'], await ctx.config(), ctx.configDir())).resolves.toThrow()
})