Last active
December 23, 2017 18:43
-
-
Save vedranjukic/21079d5161be876aabc10a81c2032001 to your computer and use it in GitHub Desktop.
Simple updateUserService test
This file contains 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
// get userRepository instance from factory | |
const userRepository = UserRepositoryInMemory() | |
const USER_ID = 1 | |
const USER_NAME_BEFORE = 'user1' | |
const USER_EMAIL_BEFORE = 'email1@test.com' | |
const USER_NAME_AFTER = 'user1_updated' | |
const USER_EMAIL_AFRTER = 'email1.updated@test.com' | |
beforeAll(async () => { | |
// first create a user we can run tests on | |
userRepository.save({ | |
userId: USER_ID, | |
userName: USER_NAME_BEFORE, | |
userEmail: USER_EMAIL_BEFORE | |
}) | |
}) | |
it('should update user', async () => { | |
expect.assertions(1) | |
await updateUser({ | |
userRepository, | |
updateParams: { | |
userId: USER_ID, | |
userName: USER_NAME_AFTER, | |
userEmail: USER_EMAIL_AFTER | |
} | |
}) | |
const updatedUser = await userRepository.getById(USER_ID) | |
expect(updatedUser).toMatchObject({ | |
userId: USER_ID, | |
userName: USER_NAME_BEFORE, | |
userEmail: USER_EMAIL_BEFORE | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment