add schema tests for commit field

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2018-12-20 18:46:49 +01:00
parent 2a91a1422f
commit a42f78b710
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
2 changed files with 22 additions and 7 deletions

View File

@ -18,11 +18,28 @@ const BUILD = {
describe('Schema', () => {
beforeEach(() => {
/* 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', () => {
it('can be a string', async () => {
it('has to be a URL', async () => {
let rval = await Joi.validate(build, Schema)
expect(rval).to.eql(build)
})
@ -35,11 +52,7 @@ describe('Schema', () => {
it('can\'t be a number', async () => {
build.pkg_url = 1
try {
await Joi.validate(build, Schema)
} catch (err) {
expect(err.message).to.contain('"pkg_url" must be a string')
}
expect(Joi.validate(build, Schema)).to.be.rejectedWith('"pkg_url" must be a string')
})
})
})

View File

@ -1,4 +1,6 @@
import chai from 'chai'
import sinonChai from 'sinon-chai'
import chaiAsPromised from 'chai-as-promised'
chai.use(sinonChai)
chai.use(chaiAsPromised);