From 4bf37b6d266ca0bb79b6abe81ce48dd8cce0dc2f Mon Sep 17 00:00:00 2001 From: Sebastian Martinez Date: Wed, 12 Jul 2023 10:57:22 +0200 Subject: [PATCH] Add support functions for httpd-api tests Signed-off-by: Sebastian Martinez --- httpd-client/tests/support/support.ts | 59 +++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 httpd-client/tests/support/support.ts diff --git a/httpd-client/tests/support/support.ts b/httpd-client/tests/support/support.ts new file mode 100644 index 000000000..dbb87e89e --- /dev/null +++ b/httpd-client/tests/support/support.ts @@ -0,0 +1,59 @@ +import type { HttpdClient } from "@httpd-client"; + +import { expect } from "vitest"; +import { isMatch } from "lodash"; + +import { cobRid } from "@tests/support/fixtures"; + +export async function createIssueToBeModified( + api: HttpdClient, + sessionId: string, +) { + const { id } = await api.project.createIssue( + cobRid, + { title: "aaa", description: "bbb", assignees: [], tags: [] }, + sessionId, + ); + + return id; +} + +export async function createPatchToBeModified( + api: HttpdClient, + sessionId: string, +) { + const { id } = await api.project.createPatch( + cobRid, + { + title: "rrr", + description: "ttt", + target: "d7dd8cecae16b1108234e09dbdb5d64ae394bc25", + oid: "38c225e2a0b47ba59def211f4e4825c31d9463ec", + tags: [], + }, + sessionId, + ); + + return id; +} +export async function assertIssue( + oid: string, + change: Record, + api: HttpdClient, +) { + expect( + //@prettier-ignore looks more readable than what prettier suggests. + isMatch(await api.project.getIssueById(cobRid, oid), change), + ).toBe(true); +} + +export async function assertPatch( + oid: string, + change: Record, + api: HttpdClient, +) { + expect( + //@prettier-ignore looks more readable than what prettier suggests. + isMatch(await api.project.getPatchById(cobRid, oid), change), + ).toBe(true); +}