diff --git a/packages/server/src/api/routes/tests/datasource.spec.ts b/packages/server/src/api/routes/tests/datasource.spec.ts index 3d98acdf0c..7545253181 100644 --- a/packages/server/src/api/routes/tests/datasource.spec.ts +++ b/packages/server/src/api/routes/tests/datasource.spec.ts @@ -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 }, diff --git a/packages/server/src/api/routes/tests/utilities/TestFunctions.ts b/packages/server/src/api/routes/tests/utilities/TestFunctions.ts index a9a8e7051b..6fa9e054b9 100644 --- a/packages/server/src/api/routes/tests/utilities/TestFunctions.ts +++ b/packages/server/src/api/routes/tests/utilities/TestFunctions.ts @@ -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]) +}