Convert mongodb.spec.ts
This commit is contained in:
parent
6b9b0801a8
commit
85d42002f9
|
@ -1,8 +1,7 @@
|
||||||
import { Datasource, Query } from "@budibase/types"
|
import { Datasource, Query } from "@budibase/types"
|
||||||
import * as setup from "../utilities"
|
|
||||||
import {
|
import {
|
||||||
DatabaseName,
|
DatabaseName,
|
||||||
getDatasource,
|
datasourceDescribe,
|
||||||
} from "../../../../integrations/tests/utils"
|
} from "../../../../integrations/tests/utils"
|
||||||
import { MongoClient, type Collection, BSON, Db } from "mongodb"
|
import { MongoClient, type Collection, BSON, Db } from "mongodb"
|
||||||
import { generator } from "@budibase/backend-core/tests"
|
import { generator } from "@budibase/backend-core/tests"
|
||||||
|
@ -10,9 +9,10 @@ import { generator } from "@budibase/backend-core/tests"
|
||||||
const expectValidId = expect.stringMatching(/^\w{24}$/)
|
const expectValidId = expect.stringMatching(/^\w{24}$/)
|
||||||
const expectValidBsonObjectId = expect.any(BSON.ObjectId)
|
const expectValidBsonObjectId = expect.any(BSON.ObjectId)
|
||||||
|
|
||||||
describe("/queries", () => {
|
datasourceDescribe(
|
||||||
|
{ name: "/queries", only: [DatabaseName.MONGODB] },
|
||||||
|
({ config, dsProvider }) => {
|
||||||
let collection: string
|
let collection: string
|
||||||
let config = setup.getConfig()
|
|
||||||
let datasource: Datasource
|
let datasource: Datasource
|
||||||
|
|
||||||
async function createQuery(query: Partial<Query>): Promise<Query> {
|
async function createQuery(query: Partial<Query>): Promise<Query> {
|
||||||
|
@ -63,15 +63,9 @@ describe("/queries", () => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
afterAll(async () => {
|
|
||||||
setup.afterAll()
|
|
||||||
})
|
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await config.init()
|
const ds = await dsProvider
|
||||||
datasource = await config.api.datasource.create(
|
datasource = ds.datasource!
|
||||||
await getDatasource(DatabaseName.MONGODB)
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
@ -319,7 +313,9 @@ describe("/queries", () => {
|
||||||
const query = await createQuery({
|
const query = await createQuery({
|
||||||
fields: {
|
fields: {
|
||||||
json: {
|
json: {
|
||||||
filter: { _id: { $eq: `ObjectId("${insertResult.insertedId}")` } },
|
filter: {
|
||||||
|
_id: { $eq: `ObjectId("${insertResult.insertedId}")` },
|
||||||
|
},
|
||||||
update: { $set: { name: "newName" } },
|
update: { $set: { name: "newName" } },
|
||||||
},
|
},
|
||||||
extra: {
|
extra: {
|
||||||
|
@ -717,4 +713,5 @@ describe("/queries", () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in New Issue