52 lines
2 KiB
JavaScript
52 lines
2 KiB
JavaScript
const assert = require('assert').strict
|
|
const loader = require('../src/loader')
|
|
const logging = require('../src/logging')
|
|
const expect = require('chai').expect
|
|
|
|
logging.init(-1)
|
|
const commands = loader.load()
|
|
|
|
|
|
describe("gen command", () => {
|
|
it('throws an error on missing name', () => {
|
|
expect(() => commands.gen.run({ })).to.throw('Name must not be empty!')
|
|
})
|
|
it('throws an error on missing description', () => {
|
|
expect(() => commands.gen.run({ name: 'testename' })).to.throw('Description must not be empty!')
|
|
})
|
|
it('generates a spec', () => {
|
|
let spec = commands.gen.run({
|
|
name: 'test-service',
|
|
description: 'Description for service.',
|
|
baseurl: 'https://nclazz.de',
|
|
namspace: 'de.nclazz'
|
|
});
|
|
expect(spec).to.not.equal(null)
|
|
expect(spec).to.not.equal(undefined)
|
|
expect(spec).to.not.equal({})
|
|
})
|
|
it('includes [name, description, base_url, namespace] as top level properties', () => {
|
|
let spec = commands.gen.run({
|
|
name: 'test-service',
|
|
description: 'Description for service.',
|
|
baseurl: 'https://nclazz.de',
|
|
namespace: 'de.nclazz'
|
|
});
|
|
expect(spec).to.have.ownProperty('name')
|
|
expect(spec).to.have.ownProperty('description')
|
|
expect(spec).to.have.ownProperty('base_url')
|
|
expect(spec).to.have.ownProperty('namespace')
|
|
})
|
|
it('correctly propagates [name, description, base_url, namespace] to spec', () => {
|
|
let spec = commands.gen.run({
|
|
name: 'test-service',
|
|
description: 'Description for service.',
|
|
baseurl: 'https://nclazz.de',
|
|
namespace: 'de.nclazz'
|
|
});
|
|
expect(spec.name).to.equal('test-service')
|
|
expect(spec.description).to.equal('Description for service.')
|
|
expect(spec.base_url).to.equal('https://nclazz.de')
|
|
expect(spec.namespace).to.equal('de.nclazz')
|
|
})
|
|
}) |