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