1
0
Fork 0
mirror of synced 2024-06-14 00:14:39 +12:00
budibase/qa-core/src/jest/globalTeardown.ts

33 lines
867 B
TypeScript
Raw Normal View History

2023-05-31 02:08:37 +12:00
import { AccountInternalAPI } from "../account-api"
import { BudibaseInternalAPI } from "../internal-api"
import { APIRequestOpts } from "../types"
const accountsApi = new AccountInternalAPI({})
const internalApi = new BudibaseInternalAPI({})
const API_OPTS: APIRequestOpts = { doExpect: false }
async function deleteAccount() {
// @ts-ignore
const accountID = global.qa.accountId
2023-07-20 02:42:12 +12:00
const [response] = await accountsApi.accounts.delete(accountID, {
doExpect: false,
})
if (response.status !== 204) {
throw new Error(`status: ${response.status} not equal to expected: 201`)
}
2023-05-31 02:08:37 +12:00
}
async function teardown() {
console.log("\nGLOBAL TEARDOWN STARTING")
2023-05-31 02:08:37 +12:00
const env = await internalApi.environment.getEnvironment(API_OPTS)
if (env.multiTenancy) {
await deleteAccount()
}
console.log("GLOBAL TEARDOWN COMPLETE")
}
export default teardown