Skip to content

Commit

Permalink
test(csi-1130): add date validation test for get quotes (#387)
Browse files Browse the repository at this point in the history
test: add date validation test for get quotes
  • Loading branch information
oderayi authored Jan 22, 2025
1 parent af185ca commit bbd7e91
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
"@hapi/inert": "7.1.0",
"@hapi/vision": "7.0.3",
"@mojaloop/central-services-error-handling": "13.0.3",
"@mojaloop/central-services-health": "15.0.1",
"@mojaloop/central-services-health": "15.0.2",
"@mojaloop/central-services-logger": "11.5.2",
"@mojaloop/central-services-metrics": "12.4.3",
"@mojaloop/central-services-shared": "18.15.2",
Expand Down
27 changes: 27 additions & 0 deletions test/unit/serverStart.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,33 @@ describe('Server Start', () => {
expect(response.statusCode).toBe(202)
})

it('get /quotes/{id} throws error when missing mandatory header', async () => {
// Act

const requests = Mockgen().requestsAsync('/quotes/{id}', 'get')
const mock = await requests

// Arrange
const headers = defaultHeaders()
delete headers.date
const expectedResult = {
errorInformation: {
errorCode: '3101',
errorDescription: 'Malformed syntax - Invalid date header'
}
}

const options = {
method: 'get',
url: '' + mock.request.path,
headers
}
// Act
const response = await server.inject(options)
expect(response.statusCode).toBe(400)
expect(response.result).toEqual(expectedResult)
})

it('post /quotes calls QuotesPost handler', async () => {
// Act
const payload = mocks.postQuotesPayloadDto()
Expand Down

0 comments on commit bbd7e91

Please sign in to comment.