Adding expect function to allow undefined.
This commit is contained in:
parent
97919821ac
commit
a9acc7f87b
|
@ -1,5 +1,5 @@
|
||||||
import * as setup from "./utilities"
|
import * as setup from "./utilities"
|
||||||
import { checkBuilderEndpoint } from "./utilities/TestFunctions"
|
import { checkBuilderEndpoint, allowUndefined } from "./utilities/TestFunctions"
|
||||||
import { getCachedVariable } from "../../../threads/utils"
|
import { getCachedVariable } from "../../../threads/utils"
|
||||||
import { context, events } from "@budibase/backend-core"
|
import { context, events } from "@budibase/backend-core"
|
||||||
import sdk from "../../../sdk"
|
import sdk from "../../../sdk"
|
||||||
|
@ -26,14 +26,6 @@ import { tableForDatasource } from "../../../tests/utilities/structures"
|
||||||
import nock from "nock"
|
import nock from "nock"
|
||||||
import { Knex } from "knex"
|
import { Knex } from "knex"
|
||||||
|
|
||||||
function fetchedSchemaProps() {
|
|
||||||
return {
|
|
||||||
externalType: expect.toBeOneOf([expect.any(String), undefined, null]),
|
|
||||||
constraints: expect.toBeOneOf([expect.anything(), undefined, null]),
|
|
||||||
autocolumn: expect.toBeOneOf([expect.anything(), undefined, null]),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
describe("/datasources", () => {
|
describe("/datasources", () => {
|
||||||
const config = setup.getConfig()
|
const config = setup.getConfig()
|
||||||
let datasource: Datasource
|
let datasource: Datasource
|
||||||
|
@ -397,7 +389,9 @@ describe("/datasources", () => {
|
||||||
(acc, [fieldName, field]) => {
|
(acc, [fieldName, field]) => {
|
||||||
acc[fieldName] = {
|
acc[fieldName] = {
|
||||||
...field,
|
...field,
|
||||||
...fetchedSchemaProps(),
|
externalType: allowUndefined(expect.any(String)),
|
||||||
|
constraints: allowUndefined(expect.any(Object)),
|
||||||
|
autocolumn: allowUndefined(expect.any(Boolean)),
|
||||||
}
|
}
|
||||||
return acc
|
return acc
|
||||||
},
|
},
|
||||||
|
|
|
@ -184,3 +184,7 @@ export const runInProd = async (func: any) => {
|
||||||
env._set("NODE_ENV", nodeEnv)
|
env._set("NODE_ENV", nodeEnv)
|
||||||
env._set("JEST_WORKER_ID", workerId)
|
env._set("JEST_WORKER_ID", workerId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function allowUndefined(expectation: jest.Expect) {
|
||||||
|
return expect.toBeOneOf([expectation, undefined, null])
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue