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

Commit

Permalink
unit(route): ensure comment votes list works
Browse files Browse the repository at this point in the history
  • Loading branch information
Angelo Magtoto committed Oct 11, 2022
1 parent 30b1f83 commit 92a44fd
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions routes/api/comment_vote/list.get.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import ErrorBag from "$!/errors/error_bag"
import MockRequester from "~/setups/mock_requester"

import Controller from "./list.get"

const QUERY_VALIDATION_INDEX = 0

describe("Controller: GET /api/comment_vote", () => {
const requester = new MockRequester()

it("can accept valid info", async() => {
const controller = new Controller()
const { validations } = controller
const queryValidation = validations[QUERY_VALIDATION_INDEX]
const queryValidationFunction = queryValidation.intermediate.bind(queryValidation)
requester.customizeRequest({
"query": {
"filter": {
"existence": "*"
}
}
})

await requester.runMiddleware(queryValidationFunction)

requester.expectSuccess()
})

it("cannot accept invalid info", async() => {
const controller = new Controller()
const { validations } = controller
const queryValidation = validations[QUERY_VALIDATION_INDEX]
const queryValidationFunction = queryValidation.intermediate.bind(queryValidation)
requester.customizeRequest({
"query": {
"filter": {
"existence": "hello"
}
}
})

await requester.runMiddleware(queryValidationFunction)

const body = requester.expectFailure(ErrorBag).toJSON()
expect(body).toHaveLength(1)
expect(body).toHaveProperty("0.source.parameter", "filter.existence")
})
})

0 comments on commit 92a44fd

Please sign in to comment.