Created
December 28, 2021 20:08
-
-
Save HonzaMac/4dfa6c70761e516a4c413c182bc6a23e to your computer and use it in GitHub Desktop.
optimized test case in part of Given
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
import { updateUser } from "./userService" | |
import { createUser } from "../tests/helpers/createUser" | |
describe('UserService - updateUser', () => { | |
it('should update department', () => { | |
// GIVEN | |
const user = createUser() | |
const updateData = { | |
department: 'IT Support', | |
} | |
// WHEN | |
const currentUser = updateUser(user, updateData) | |
// THEN | |
expect(currentUser).toStrictEqual({ | |
id: 'e2f5a82a-3f2e-4b6d-b4d2-086afaa08f8a', | |
username: 'john', | |
email: '[email protected]', | |
country: 'France', | |
department: 'IT Support', | |
divisionName: 'IT', | |
}) | |
}) | |
}) |
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
import { User } from "../../src/userService" | |
export const createUser = (data: Partial<User> = {}) => ({ | |
id: 'e2f5a82a-3f2e-4b6d-b4d2-086afaa08f8a', | |
username: 'john', | |
email: '[email protected]', | |
country: 'France', | |
department: 'IT Services', | |
divisionName: 'IT', | |
...data, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment