Created
December 26, 2021 20:59
-
-
Save HonzaMac/a977435848714be3f340c1eb55f8ae8f to your computer and use it in GitHub Desktop.
initial test case prior optimization
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" | |
describe('UserService - updateUser', () => { | |
it('should update department', () => { | |
// GIVEN | |
const user = { | |
id: 'e2f5a82a-3f2e-4b6d-b4d2-086afaa08f8a', | |
username: 'john', | |
email: '[email protected]', | |
country: 'France', | |
department: 'IT Services', | |
divisionName: 'IT', | |
} | |
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', | |
}) | |
}) | |
it.todo('should not update on empty update'); | |
it.todo('should update divisionName'); | |
}) |
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
export interface User { | |
username: string; | |
email: string; | |
country: string; | |
department: string; | |
divisionName: string; | |
city?: string; | |
} | |
export const updateUser = (user: User, updateData: Partial<User>): User => ({ | |
...user, | |
...updateData, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment