Last active
March 21, 2019 18:07
-
-
Save abnersajr/0188835128c4a7814aa7a72d54306a7d to your computer and use it in GitHub Desktop.
Mappers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Not the best way to write components and tests, having different names for same data | |
const UserProfile = ({ name, lastName, birthDate, userEvaluation }) => { | |
const fullName = `${name} ${lastName}` | |
... | |
} | |
describe('UserProfile', () => { | |
it('renders with correct props', () => { | |
const MOCK_USER = { | |
name: 'Abner', | |
lastName: 'Alves', | |
birthDate: '31/02/3019', | |
userEvaluation: 'topster' | |
}; | |
const wrapper = shallow(<UserProfile {...MOCK_USER} />); | |
... | |
}) | |
}) | |
// But if the API response doesn't have the same shape of our mock, our component will stop working | |
describe('UserProfile', () => { | |
it('renders with correct props', () => { | |
const ACTUAL_API_RESPONSE = { | |
userName: "Talysson", | |
userLastName: "Cassiano", | |
birth: "01/04/1992", | |
evaluation: { | |
average: 4.5, | |
total: 20, | |
} | |
} | |
const wrapper = shallow(<UserProfile {...ACTUAL_API_RESPONSE} />); | |
... | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment