Type tests utils

This commit is contained in:
Adria Navarro 2023-01-17 17:19:39 +00:00
parent 70168a20fa
commit 6412da730c
2 changed files with 13 additions and 7 deletions

View File

@ -1,20 +1,24 @@
import * as setup from "../../tests/utilities"
import { checkSlashesInUrl } from "../../../../utilities"
import supertest from "supertest"
export type HttpMethod = "post" | "get"
export type MakeRequestResponse = (
method: string,
method: HttpMethod,
endpoint: string,
body?: any,
intAppId?: string
) => Promise<any>
) => Promise<supertest.Response>
export function generateMakeRequest(apiKey: string, setup: any) {
const request = setup.getRequest()
export function generateMakeRequest(apiKey: string): MakeRequestResponse {
const request = setup.getRequest()!
const config = setup.getConfig()
return async (
method: string,
method: HttpMethod,
endpoint: string,
body?: any,
intAppId: string = config.getAppId()
intAppId: string | null = config.getAppId()
) => {
const extraHeaders: any = {
"x-budibase-api-key": apiKey,

View File

@ -1,5 +1,6 @@
import TestConfig from "../../../../tests/utilities/TestConfiguration"
import env from "../../../../environment"
import supertest from "supertest"
export * as structures from "../../../../tests/utilities/structures"
function user() {
@ -44,7 +45,8 @@ export function delay(ms: number) {
return new Promise(resolve => setTimeout(resolve, ms))
}
let request: any, config: TestConfig
let request: supertest.SuperTest<supertest.Test> | undefined | null,
config: TestConfig
export function beforeAll() {
config = new TestConfig()