Skip to content

Commit

Permalink
improving test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
nikiwycherley committed Nov 13, 2023
1 parent 2f1ebc7 commit bf4d1c4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/cap.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "bodyXml": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<alert xmlns=\"urn:oasis:names:tc:emergency:cap:1.2\">\r\n <identifier>4eb3b7350ab7aa443650fc9351f02940E</identifier>\r\n <sender>www.gov.uk/environment-agency</sender>\r\n <sent>2023-10-11T11:00:02-00:00</sent>\r\n <status>Actual</status>\r\n <msgType>Alert</msgType>\r\n <source>Flood warning service</source>\r\n <scope>Public</scope>\r\n <info>\r\n <language>en-GB</language>\r\n <category>Met</category>\r\n <event><![CDATA[064 Issue Flood Alert EA]]></event>\r\n <urgency>Immediate</urgency><expires>2025-09-20T11:00:02-00:00</expires><area><geocode><valueName>TargetAreaCode</valueName><value><![CDATA[TESTAREA1]]></value></geocode></area></info></alert>" }
7 changes: 7 additions & 0 deletions test/getMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,11 @@ lab.experiment('getMessage', () => {
event = {}
await Code.expect(getMessage(event)).to.reject()
})
lab.test('Invalid id format test', async () => {
// Set the id to a value that is not a hexadecimal string
event.pathParameters.id = 'invalid_id_format'

// Expect the getMessage function to reject due to validation failure
await Code.expect(getMessage(event)).to.reject()
})
})
7 changes: 7 additions & 0 deletions test/processMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,4 +316,11 @@ lab.experiment('processMessage', () => {
Code.expect(ret.body.status).to.not.equal('Test')
Code.expect(ret.body.status).to.equal('Actual')
})
lab.test('Invalid bodyXml format test', async () => {
// Set bodyXml to an invalid value (e.g., null, undefined, or an object)
const invalidBodyXml = null

// Expect the processMessage function to reject due to validation failure
await Code.expect(processMessage({ bodyXml: invalidBodyXml })).to.reject()
})
})

0 comments on commit bf4d1c4

Please sign in to comment.