Skip to content

Instantly share code, notes, and snippets.

@vedranjukic
Last active December 23, 2017 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vedranjukic/21079d5161be876aabc10a81c2032001 to your computer and use it in GitHub Desktop.
Save vedranjukic/21079d5161be876aabc10a81c2032001 to your computer and use it in GitHub Desktop.
Simple updateUserService test
// 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