|
| 1 | +import { AbstractCommand } from '../../../src/commands/abstract-command' |
| 2 | +import { Deploy } from '../../../src/commands/deploy' |
| 3 | +import * as path from 'path' |
| 4 | + |
| 5 | +describe('test for deploy command', () => { |
| 6 | + let deploy: AbstractCommand |
| 7 | + const pathToProjectDir = './test/commands/deploy/inner-dir' |
| 8 | + const pathToProjectNoPackage = './test/commands/deploy/inner-dir-no-package' |
| 9 | + const absoluteProcessDir = path.join(process.cwd(), pathToProjectDir) |
| 10 | + const absoluteProcessDirNoPackage = path.join(process.cwd(), pathToProjectNoPackage) |
| 11 | + |
| 12 | + beforeAll(() => { |
| 13 | + deploy = new Deploy() |
| 14 | + }) |
| 15 | + |
| 16 | + it('works if action returns a function', () => { |
| 17 | + const act = deploy.getAction() |
| 18 | + expect(act).toBeInstanceOf(Function) |
| 19 | + }) |
| 20 | + |
| 21 | + it('works if deploy command is executed in directory', async () => { |
| 22 | + const act = deploy.getAction() |
| 23 | + const spy = jest.spyOn(deploy as any, 'getDeployCommand') |
| 24 | + await act(undefined) |
| 25 | + expect(spy).toHaveBeenCalled() |
| 26 | + spy.mockRestore() |
| 27 | + }) |
| 28 | + |
| 29 | + it('works if deploy command is executed with directory path', async () => { |
| 30 | + const act = deploy.getAction() |
| 31 | + const spy = jest.spyOn(deploy as any, 'getDeployCommand') |
| 32 | + await act(absoluteProcessDir) |
| 33 | + expect(spy).toHaveBeenCalled() |
| 34 | + spy.mockRestore() |
| 35 | + }) |
| 36 | + |
| 37 | + it('works if deploy command is not executed when no package.json', async () => { |
| 38 | + const act = deploy.getAction() |
| 39 | + const spy = jest.spyOn(deploy as any, 'getDeployCommand') |
| 40 | + await act(absoluteProcessDirNoPackage) |
| 41 | + expect(spy).not.toHaveBeenCalled() |
| 42 | + spy.mockRestore() |
| 43 | + }) |
| 44 | +}) |
0 commit comments