Testing the Response
Recall how we implemented the userResponseDto.
File: src/responses/userResponseDto.js
const userResponseDto = (user) => {
return {
id: user['id'],
first_name: user['first_name'],
last_name: user['last_name'],
email: user['email'],
phone_number: user['phone_number']
}
}
module.exports = userResponseDtoYou may look at this and feel a sense of déjà vu, and you would be right, because writing a test for the userResponseDto is quite similar to writing a test for the registerUserRequestDto.
As always we'll setup our test suite as follows.
File: src/responses/__tests/userResponseDto.test.js
const userResponseDto = require('../userResponseDto')
describe('Test Suite: userResponseDto', () => {
// Tests go here
})The Tests
Since this is quite an easy function to test, let's add in some more test cases this time.
Last updated