Last active
December 28, 2021 21:39
-
-
Save HonzaMac/2a245be5cef47e4b0ee4a9acaf75ba49 to your computer and use it in GitHub Desktop.
basic short then test case
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 * as faker from "faker" | |
import { User } from "../../src/userService" | |
export const createUser = (data: Partial<User> = {}) : User => { | |
const fakeData: User = { | |
id: faker.datatype.uuid(), | |
username: faker.name.findName(), | |
email: faker.internet.email(), | |
country: faker.address.country(), | |
department: faker.company.companyName(), | |
divisionName: faker.name.jobArea(), | |
} | |
return { | |
...fakeData, | |
...data, | |
} | |
}; |
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).toMatchObject({ | |
id: user.id, | |
department: updateData.department, | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment