Skip to content

Commit

Permalink
test(billingservice): updated tests to use dto for params
Browse files Browse the repository at this point in the history
  • Loading branch information
seaerchin committed Apr 1, 2021
1 parent 1f08ca9 commit 300f708
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
4 changes: 3 additions & 1 deletion src/app/modules/billing/__tests__/billing.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ describe('billing.controller', () => {
...EXPECTED_SERVICE_CALL_ARGS,
)
expect(mockRes.status).toBeCalledWith(500)
expect(mockRes.json).toBeCalledWith('Error in retrieving billing records')
expect(mockRes.json).toBeCalledWith({
message: 'Error in retrieving billing records',
})
})
})
})
4 changes: 3 additions & 1 deletion src/app/modules/billing/__tests__/billing.routes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ describe('billing.routes', () => {
// Assert
expect(retrieveStatsSpy).toBeCalled()
expect(response.status).toEqual(500)
expect(response.body).toEqual('Error in retrieving billing records')
expect(response.body).toEqual({
message: 'Error in retrieving billing records',
})
})
})
})
Expand Down
13 changes: 2 additions & 11 deletions src/public/services/__tests__/BillingService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ describe('BillingService', () => {
MockAxios.get.mockResolvedValueOnce({ data: MOCK_DATA })

// Act
const actual = await BillingService.getBillingInfo(
MOCK_PARAMS.yr,
MOCK_PARAMS.mth,
MOCK_PARAMS.esrvcId,
)
const actual = await BillingService.getBillingInfo(MOCK_PARAMS)

// Assert
expect(MockAxios.get).toHaveBeenCalledWith(
Expand All @@ -38,12 +34,7 @@ describe('BillingService', () => {
it('should reject with the provided error message when the GET request fails', async () => {
// Arrange
const expected = new Error('Mock Error')
const shouldReject = () =>
BillingService.getBillingInfo(
MOCK_PARAMS.yr,
MOCK_PARAMS.mth,
MOCK_PARAMS.esrvcId,
)
const shouldReject = () => BillingService.getBillingInfo(MOCK_PARAMS)
MockAxios.get.mockRejectedValueOnce(expected)

// Act
Expand Down

0 comments on commit 300f708

Please sign in to comment.