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

Commit

Permalink
unit(role): update the tests to delete roles
Browse files Browse the repository at this point in the history
  • Loading branch information
KennethTrecy committed Sep 16, 2022
1 parent e618389 commit f2b951d
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions routes/api/role/archive.delete.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Factory from "~/factories/role"
import ErrorBag from "$!/errors/error_bag"
import RoleFactory from "~/factories/role"
import UserFactory from "~/factories/user"
import MockRequester from "~/set-ups/mock_requester"

import Controller from "./archive.delete"
Expand All @@ -14,13 +15,14 @@ describe("Controller: DELETE /api/role", () => {
const { validations } = controller
const bodyValidation = validations[BODY_VALIDATION_INDEX]
const bodyValidationFunction = bodyValidation.intermediate.bind(bodyValidation)
const role = await new RoleFactory().insertOne()
const model = await new Factory().insertOne()
await new UserFactory().attach(model).insertOne()
requester.customizeRequest({
"body": {
"data": [
{
"type": "role",
"id": String(role.id)
"id": String(model.id),
"type": "role"
}
]
}
Expand All @@ -36,14 +38,14 @@ describe("Controller: DELETE /api/role", () => {
const { validations } = controller
const bodyValidation = validations[BODY_VALIDATION_INDEX]
const bodyValidationFunction = bodyValidation.intermediate.bind(bodyValidation)
const role = await new RoleFactory().insertOne()
await role.destroy({ "force": false })
const model = await new Factory().insertOne()
await model.destroy({ "force": false })
requester.customizeRequest({
"body": {
"data": [
{
"type": "role",
"id": String(role.id)
"id": String(model.id),
"type": "role"
}
]
}
Expand All @@ -61,14 +63,14 @@ describe("Controller: DELETE /api/role", () => {
const { validations } = controller
const bodyValidation = validations[BODY_VALIDATION_INDEX]
const bodyValidationFunction = bodyValidation.intermediate.bind(bodyValidation)
const role = await new RoleFactory().insertOne()
await role.destroy({ "force": true })
const model = await new Factory().insertOne()
await model.destroy({ "force": true })
requester.customizeRequest({
"body": {
"data": [
{
"type": "role",
"id": String(role.id)
"id": String(model.id),
"type": "role"
}
]
}
Expand Down

0 comments on commit f2b951d

Please sign in to comment.