generated from HugoMendes98/Nx-NestJS-Angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(api): add test for boolean order
- Loading branch information
Mendes Hugo
committed
Sep 25, 2023
1 parent
c730989
commit ed80657
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
apps/backend-e2e/src/backend/http/v1/workflows.http.spec.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { AxiosError, HttpStatusCode } from "axios"; | ||
import { Jsonify } from "type-fest"; | ||
import { DbE2eHelper } from "~/app/backend/e2e/db-e2e/db-e2e.helper"; | ||
import { WorkflowHttpClient } from "~/app/backend/e2e/http/clients/workflow.http-client"; | ||
import { WorkflowQueryDto } from "~/lib/common/app/workflow/dtos"; | ||
import { WORKFLOWS_ENDPOINT_PREFIX } from "~/lib/common/app/workflow/endpoints"; | ||
import { BASE_SEED } from "~/lib/common/seeds"; | ||
|
||
describe("Backend HTTP Graphs", () => { | ||
const client = new WorkflowHttpClient(); | ||
|
||
const dbHelper = DbE2eHelper.getHelper("base"); | ||
const db = JSON.parse(JSON.stringify(dbHelper.db)) as Jsonify<typeof BASE_SEED>; | ||
|
||
beforeAll(async () => { | ||
const [{ email, password }] = db.users; | ||
|
||
await dbHelper.refresh(); | ||
await client.setAuth(email, password); | ||
}); | ||
|
||
describe(`GET ${WORKFLOWS_ENDPOINT_PREFIX}`, () => { | ||
beforeAll(() => dbHelper.refresh()); | ||
|
||
it("should order by boolean properties", async () => { | ||
const response = await client | ||
.findManyResponse({ | ||
params: { order: [{ active: "desc" }] } satisfies WorkflowQueryDto | ||
}) | ||
.catch(({ response }: AxiosError) => response!); | ||
|
||
expect(response.status).toBe(HttpStatusCode.Ok); | ||
}); | ||
}); | ||
}); |
10 changes: 10 additions & 0 deletions
10
apps/backend-e2e/src/support/http/clients/workflow.http-client.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { WorkflowDto } from "~/lib/common/app/workflow/dtos"; | ||
import { WORKFLOWS_ENDPOINT_PREFIX } from "~/lib/common/app/workflow/endpoints"; | ||
|
||
import { EntityHttpClient } from "./_lib/entity.http-client"; | ||
|
||
export class WorkflowHttpClient extends EntityHttpClient<WorkflowDto> { | ||
public override getEndpoint(): string { | ||
return WORKFLOWS_ENDPOINT_PREFIX; | ||
} | ||
} |