Type tests utils
This commit is contained in:
parent
70168a20fa
commit
6412da730c
|
@ -1,20 +1,24 @@
|
||||||
|
import * as setup from "../../tests/utilities"
|
||||||
import { checkSlashesInUrl } from "../../../../utilities"
|
import { checkSlashesInUrl } from "../../../../utilities"
|
||||||
|
import supertest from "supertest"
|
||||||
|
|
||||||
|
export type HttpMethod = "post" | "get"
|
||||||
|
|
||||||
export type MakeRequestResponse = (
|
export type MakeRequestResponse = (
|
||||||
method: string,
|
method: HttpMethod,
|
||||||
endpoint: string,
|
endpoint: string,
|
||||||
body?: any,
|
body?: any,
|
||||||
intAppId?: string
|
intAppId?: string
|
||||||
) => Promise<any>
|
) => Promise<supertest.Response>
|
||||||
|
|
||||||
export function generateMakeRequest(apiKey: string, setup: any) {
|
export function generateMakeRequest(apiKey: string): MakeRequestResponse {
|
||||||
const request = setup.getRequest()
|
const request = setup.getRequest()!
|
||||||
const config = setup.getConfig()
|
const config = setup.getConfig()
|
||||||
return async (
|
return async (
|
||||||
method: string,
|
method: HttpMethod,
|
||||||
endpoint: string,
|
endpoint: string,
|
||||||
body?: any,
|
body?: any,
|
||||||
intAppId: string = config.getAppId()
|
intAppId: string | null = config.getAppId()
|
||||||
) => {
|
) => {
|
||||||
const extraHeaders: any = {
|
const extraHeaders: any = {
|
||||||
"x-budibase-api-key": apiKey,
|
"x-budibase-api-key": apiKey,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import TestConfig from "../../../../tests/utilities/TestConfiguration"
|
import TestConfig from "../../../../tests/utilities/TestConfiguration"
|
||||||
import env from "../../../../environment"
|
import env from "../../../../environment"
|
||||||
|
import supertest from "supertest"
|
||||||
export * as structures from "../../../../tests/utilities/structures"
|
export * as structures from "../../../../tests/utilities/structures"
|
||||||
|
|
||||||
function user() {
|
function user() {
|
||||||
|
@ -44,7 +45,8 @@ export function delay(ms: number) {
|
||||||
return new Promise(resolve => setTimeout(resolve, ms))
|
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() {
|
export function beforeAll() {
|
||||||
config = new TestConfig()
|
config = new TestConfig()
|
||||||
|
|
Loading…
Reference in New Issue