1
0
Fork 0
mirror of synced 2024-05-04 12:33:42 +12:00
budibase/qa-core/src/config/internal-api/TestConfiguration/screens.ts
2022-11-07 15:48:24 +00:00

28 lines
859 B
TypeScript

import { Screen } from "@budibase/types"
import { Response } from "node-fetch"
import InternalAPIClient from "./InternalAPIClient"
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()
expect(response).toHaveStatusCode(200)
expect(json._id).toBeDefined()
expect(json.routing.roleId).toBe(body.routing.roleId)
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()
expect(response).toHaveStatusCode(200)
return [response, json]
}
}