1
0
Fork 0
mirror of synced 2024-05-18 11:23:28 +12:00
budibase/qa-core/src/config/internal-api/TestConfiguration/screens.ts

28 lines
859 B
TypeScript
Raw Normal View History

2022-10-22 06:52:39 +13:00
import { Screen } from "@budibase/types"
import { Response } from "node-fetch"
import InternalAPIClient from "./InternalAPIClient"
2022-10-22 06:52:39 +13:00
export default class ScreenApi {
api: InternalAPIClient
constructor(apiClient: InternalAPIClient) {
this.api = apiClient
}
async create(body: any): Promise<[Response, Screen]> {
const response = await this.api.post(`/screens`, { body })
const json = await response.json()
2022-11-08 04:48:24 +13:00
expect(response).toHaveStatusCode(200)
expect(json._id).toBeDefined()
expect(json.routing.roleId).toBe(body.routing.roleId)
2022-10-22 06:52:39 +13:00
return [response, json]
}
async delete(screenId: string, rev: string): Promise<[Response, Screen]> {
const response = await this.api.del(`/screens/${screenId}/${rev}`)
const json = await response.json()
2022-11-08 04:48:24 +13:00
expect(response).toHaveStatusCode(200)
2022-10-22 06:52:39 +13:00
return [response, json]
}
2022-10-22 06:52:39 +13:00
}