Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
unit(employee schedule): add test to ensure to accept same info
Browse files Browse the repository at this point in the history
  • Loading branch information
KennethTrecy committed Sep 11, 2022
1 parent 003377a commit ee759af
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions routes/api/employee_schedule/update(id).patch.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,43 @@ describe("Controller: PATCH /api/employee_schedule", () => {
requester.expectSuccess()
})

it("can accept same info", async() => {
const controller = new Controller()
const { validations } = controller
const bodyValidation = validations[BODY_VALIDATION_INDEX]
const bodyValidationFunction = bodyValidation.intermediate.bind(bodyValidation)
const user = await new UserFactory().beReachableEmployee().insertOne()
const employeeeSchedule = await new EmployeeScheduleFactory()
.dayName(() => "wednesday")
.user(() => Promise.resolve(user))
.insertOne()
requester.customizeRequest({
"body": {
"data": {
"attributes": {
"dayName": employeeeSchedule.dayName,
"scheduleEnd": employeeeSchedule.scheduleEnd,
"scheduleStart": employeeeSchedule.scheduleStart
},
"id": String(employeeeSchedule.id),
"relationships": {
"user": {
"data": {
"id": String(user.id),
"type": "user"
}
}
},
"type": "employee_schedule"
}
}
})

await requester.runMiddleware(bodyValidationFunction)

requester.expectSuccess()
})

it("cannot accept invalid name", async() => {
const controller = new Controller()
const { validations } = controller
Expand Down

0 comments on commit ee759af

Please sign in to comment.