add schema tests for commit field
Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
2a91a1422f
commit
a42f78b710
|
@ -18,11 +18,28 @@ const BUILD = {
|
||||||
describe('Schema', () => {
|
describe('Schema', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
/* refresh for every test */
|
/* refresh for every test */
|
||||||
build = Object.assign(BUILD)
|
build = Object.assign({}, BUILD)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('commit', () => {
|
||||||
|
it('has to be a commit', async () => {
|
||||||
|
let rval = await Joi.validate(build, Schema)
|
||||||
|
expect(rval).to.eql(build)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can\'t be a null', () => {
|
||||||
|
build.commit = null
|
||||||
|
expect(Joi.validate(build, Schema)).to.be.rejectedWith('"commit" must be a string')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can\'t be a number', async () => {
|
||||||
|
build.commit = 1
|
||||||
|
expect(Joi.validate(build, Schema)).to.be.rejectedWith('"commit" must be a string')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('pkg_url', () => {
|
describe('pkg_url', () => {
|
||||||
it('can be a string', async () => {
|
it('has to be a URL', async () => {
|
||||||
let rval = await Joi.validate(build, Schema)
|
let rval = await Joi.validate(build, Schema)
|
||||||
expect(rval).to.eql(build)
|
expect(rval).to.eql(build)
|
||||||
})
|
})
|
||||||
|
@ -35,11 +52,7 @@ describe('Schema', () => {
|
||||||
|
|
||||||
it('can\'t be a number', async () => {
|
it('can\'t be a number', async () => {
|
||||||
build.pkg_url = 1
|
build.pkg_url = 1
|
||||||
try {
|
expect(Joi.validate(build, Schema)).to.be.rejectedWith('"pkg_url" must be a string')
|
||||||
await Joi.validate(build, Schema)
|
|
||||||
} catch (err) {
|
|
||||||
expect(err.message).to.contain('"pkg_url" must be a string')
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
import chai from 'chai'
|
import chai from 'chai'
|
||||||
import sinonChai from 'sinon-chai'
|
import sinonChai from 'sinon-chai'
|
||||||
|
import chaiAsPromised from 'chai-as-promised'
|
||||||
|
|
||||||
chai.use(sinonChai)
|
chai.use(sinonChai)
|
||||||
|
chai.use(chaiAsPromised);
|
||||||
|
|
Loading…
Reference in New Issue