mirror of
https://github.com/serverless/serverless.git
synced 2025-12-08 19:46:03 +00:00
79 lines
2.1 KiB
JavaScript
79 lines
2.1 KiB
JavaScript
'use strict'
|
|
|
|
const { expect } = require('chai')
|
|
const overrideArgv = require('process-utils/override-argv')
|
|
const ServerlessError = require('../../../../lib/serverless-error')
|
|
const resolveInput = require('../../../../lib/cli/resolve-input')
|
|
const {
|
|
triggeredDeprecations,
|
|
} = require('../../../../lib/utils/log-deprecation')
|
|
const ensureSupportedCommand = require('../../../../lib/cli/ensure-supported-command')
|
|
|
|
describe('test/unit/lib/cli/ensure-supported-command.test.js', () => {
|
|
it('should do nothing on valid command', async () => {
|
|
resolveInput.clear()
|
|
triggeredDeprecations.clear()
|
|
overrideArgv(
|
|
{
|
|
args: ['serverless', 'login'],
|
|
},
|
|
() => resolveInput(),
|
|
)
|
|
ensureSupportedCommand()
|
|
})
|
|
|
|
it('should do nothing on container commmand', async () => {
|
|
resolveInput.clear()
|
|
triggeredDeprecations.clear()
|
|
overrideArgv(
|
|
{
|
|
args: ['serverless', 'plugin'],
|
|
},
|
|
() => resolveInput(),
|
|
)
|
|
ensureSupportedCommand()
|
|
})
|
|
|
|
it('should reject invalid command', async () => {
|
|
resolveInput.clear()
|
|
triggeredDeprecations.clear()
|
|
overrideArgv(
|
|
{
|
|
args: ['serverless', 'hablo'],
|
|
},
|
|
() => resolveInput(),
|
|
)
|
|
expect(() => ensureSupportedCommand())
|
|
.to.throw(ServerlessError)
|
|
.with.property('code', 'UNRECOGNIZED_CLI_COMMAND')
|
|
})
|
|
|
|
it('should report invalid options', async () => {
|
|
resolveInput.clear()
|
|
triggeredDeprecations.clear()
|
|
overrideArgv(
|
|
{
|
|
args: ['serverless', 'login', '--hadsfa'],
|
|
},
|
|
() => resolveInput(),
|
|
)
|
|
expect(() => ensureSupportedCommand())
|
|
.to.throw(ServerlessError)
|
|
.with.property('code', 'UNSUPPORTED_CLI_OPTIONS')
|
|
})
|
|
|
|
it('should reject missing options', async () => {
|
|
resolveInput.clear()
|
|
triggeredDeprecations.clear()
|
|
overrideArgv(
|
|
{
|
|
args: ['serverless', 'config', 'credentials'],
|
|
},
|
|
() => resolveInput(),
|
|
)
|
|
expect(() => ensureSupportedCommand())
|
|
.to.throw(ServerlessError)
|
|
.with.property('code', 'MISSING_REQUIRED_CLI_OPTION')
|
|
})
|
|
})
|