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

Commit

Permalink
unit(chat message): prepare tests route to upload chat message with file
Browse files Browse the repository at this point in the history
  • Loading branch information
KennethTrecy committed Sep 11, 2022
1 parent 5b3450a commit baf6060
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions routes/api/chat_message/create_with_file.post.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import ErrorBag from "$!/errors/error_bag"
import UserFactory from "~/factories/user"
import Factory from "~/factories/chat_message"
import MockRequester from "~/set-ups/mock_requester"
import ChatMessageActivityFactory from "~/factories/chat_message_activity"
Expand All @@ -15,7 +16,9 @@ describe("Controller: POST /api/chat_message/create_with_file", () => {
const { validations } = controller
const bodyValidation = validations[BODY_VALIDATION_INDEX]
const bodyValidationFunction = bodyValidation.intermediate.bind(bodyValidation)
const userFactory = new UserFactory()
const chatMessageActivity = await new ChatMessageActivityFactory().insertOne()
const { user } = chatMessageActivity
const model = await new Factory()
.chatMessageActivity(() => Promise.resolve(chatMessageActivity))
.makeOne()
Expand Down Expand Up @@ -44,7 +47,8 @@ describe("Controller: POST /api/chat_message/create_with_file", () => {
}
}
}
}
},
"user": userFactory.serialize(user)
})

await requester.runMiddleware(bodyValidationFunction)
Expand All @@ -59,7 +63,9 @@ describe("Controller: POST /api/chat_message/create_with_file", () => {
const { validations } = controller
const bodyValidation = validations[BODY_VALIDATION_INDEX]
const bodyValidationFunction = bodyValidation.intermediate.bind(bodyValidation)
const userFactory = new UserFactory()
const chatMessageActivity = await new ChatMessageActivityFactory().insertOne()
const { user } = chatMessageActivity
requester.customizeRequest({
"body": {
"data": {
Expand All @@ -85,7 +91,8 @@ describe("Controller: POST /api/chat_message/create_with_file", () => {
}
}
}
}
},
"user": userFactory.serialize(user)
})

await requester.runMiddleware(bodyValidationFunction)
Expand Down

0 comments on commit baf6060

Please sign in to comment.