Skip to content

Commit

Permalink
schema tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ash committed Nov 30, 2023
1 parent 1762fac commit 9139195
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
6 changes: 0 additions & 6 deletions test/getMessage.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
'use strict'

const joi = require('joi')
const Lab = require('@hapi/lab')
const lab = exports.lab = Lab.script()
const Code = require('@hapi/code')
const getMessage = require('../lib/functions/getMessage').getMessage
const getMessageEventSchema = require('../lib/helpers/schemas').getMessageEventSchema
const service = require('../lib/helpers/service')

let event
Expand Down Expand Up @@ -87,10 +85,6 @@ lab.experiment('getMessage', () => {
Code.expect(err.message).to.equal('test error')
})

lab.test('event schema', () => {
Code.expect(joi.isSchema(getMessageEventSchema)).to.equal(true)
})

lab.test('event validation test', async () => {
event.id = {}
await Code.expect(getMessage(event)).to.reject()
Expand Down
6 changes: 0 additions & 6 deletions test/processMessage.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
'use strict'

const joi = require('joi')
const Lab = require('@hapi/lab')
const lab = exports.lab = Lab.script()
const Code = require('@hapi/code')
const processMessage = require('../lib/functions/processMessage').processMessage
const processMessageEventSchema = require('../lib/helpers/schemas').processMessageEventSchema
const service = require('../lib/helpers/service')
const moment = require('moment')
let capAlert
Expand Down Expand Up @@ -280,8 +278,4 @@ lab.experiment('processMessage', () => {

await Code.expect(processMessage({ bodyXml: validBodyXml })).to.not.reject()
})

lab.test('event schema', () => {
Code.expect(joi.isSchema(processMessageEventSchema)).to.equal(true)
})
})
22 changes: 22 additions & 0 deletions test/schemas.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict'

const Joi = require('joi')
const Lab = require('@hapi/lab')
const lab = exports.lab = Lab.script()
const Code = require('@hapi/code')
const configSchema = require('../config/schema')
const { getMessageEventSchema, processMessageEventSchema } = require('../lib/helpers/schemas')

lab.experiment('schemas', () => {
lab.test('configSchema', () => {
Code.expect(Joi.isSchema(configSchema)).to.equal(true)
})

lab.test('getMessageEventSchema', () => {
Code.expect(Joi.isSchema(getMessageEventSchema)).to.equal(true)
})

lab.test('processMessageEventSchema', () => {
Code.expect(Joi.isSchema(processMessageEventSchema)).to.equal(true)
})
})

0 comments on commit 9139195

Please sign in to comment.