Skip to content

Commit

Permalink
test: update test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
oderayi committed Jun 24, 2024
1 parent 3f55ba4 commit 6f9a105
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/unit/util/participants.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,43 @@ Test('Participants Cache Test', participantsCacheTest => {
test.end()
}
})

getParticipantTest.test('throws error if hubName is not defined', async (test) => {
const fsp = 'fsp2'
const url = Mustache.render(Config.ENDPOINT_SOURCE_URL + Enum.EndPoints.FspEndpointTemplates.PARTICIPANTS_GET, { fsp })
await Cache.initializeCache(Config.ENDPOINT_CACHE_CONFIG, { hubNameRegex })
request.sendRequest.withArgs({ url, headers: Helper.defaultHeaders(), source: hubName, destination: hubName, hubNameRegex }).returns(Promise.resolve(Helper.getParticipantsResponseFsp2))

try {
await Cache.getParticipant(Config.ENDPOINT_SOURCE_URL, fsp)
test.fail('should throw error')
await Cache.stopCache()
test.end()
} catch (err) {
test.ok(err instanceof Error)
await Cache.stopCache()
test.end()
}
})

getParticipantTest.test('throws error if hubNameRegex is not defined', async (test) => {
const fsp = 'fsp2'
const url = Mustache.render(Config.ENDPOINT_SOURCE_URL + Enum.EndPoints.FspEndpointTemplates.PARTICIPANTS_GET, { fsp })
await Cache.initializeCache(Config.ENDPOINT_CACHE_CONFIG, { hubName })
request.sendRequest.withArgs({ url, headers: Helper.defaultHeaders(), source: hubName, destination: hubName, hubNameRegex }).returns(Promise.resolve(Helper.getParticipantsResponseFsp2))

try {
await Cache.getParticipant(Config.ENDPOINT_SOURCE_URL, fsp)
test.fail('should throw error')
await Cache.stopCache()
test.end()
} catch (err) {
test.ok(err instanceof Error)
await Cache.stopCache()
test.end()
}
})

await getParticipantTest.end()
})

Expand Down

0 comments on commit 6f9a105

Please sign in to comment.