add check for id field
Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
db52b7d776
commit
8c56210812
|
@ -5,6 +5,7 @@ import Joi from 'joi'
|
|||
import Schema from '../src/schema'
|
||||
|
||||
let build
|
||||
/* example valid build */
|
||||
const BUILD = {
|
||||
id: 'ID-1',
|
||||
commit: 'abcd1234',
|
||||
|
@ -21,6 +22,24 @@ describe('Schema', () => {
|
|||
build = Object.assign({}, BUILD)
|
||||
})
|
||||
|
||||
describe('id', () => {
|
||||
it('can be a string', async () => {
|
||||
let rval = await Joi.validate(build, Schema)
|
||||
expect(rval).to.eql(build)
|
||||
})
|
||||
|
||||
it('can be a number', async () => {
|
||||
build.id = 123
|
||||
let rval = await Joi.validate(build, Schema)
|
||||
expect(rval).to.eql(build)
|
||||
})
|
||||
|
||||
it('can\'t be null', () => {
|
||||
build.id = null
|
||||
expect(Joi.validate(build, Schema)).rejectedWith('"id" must be a number, "id" must be a string')
|
||||
})
|
||||
})
|
||||
|
||||
describe('commit', () => {
|
||||
it('has to be a commit', async () => {
|
||||
let rval = await Joi.validate(build, Schema)
|
||||
|
@ -32,7 +51,7 @@ describe('Schema', () => {
|
|||
expect(Joi.validate(build, Schema)).rejectedWith('"commit" must be a string')
|
||||
})
|
||||
|
||||
it('can\'t be a number', async () => {
|
||||
it('can\'t be a number', () => {
|
||||
build.commit = 1
|
||||
expect(Joi.validate(build, Schema)).rejectedWith('"commit" must be a string')
|
||||
})
|
||||
|
@ -50,7 +69,7 @@ describe('Schema', () => {
|
|||
expect(rval).to.eql(build)
|
||||
})
|
||||
|
||||
it('can\'t be a number', async () => {
|
||||
it('can\'t be a number', () => {
|
||||
build.pkg_url = 1
|
||||
expect(Joi.validate(build, Schema)).rejectedWith('"pkg_url" must be a string')
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue