Fix backend-core tests.
This commit is contained in:
parent
71000ea967
commit
c12a96b4d8
|
@ -1,24 +0,0 @@
|
|||
require("../../../tests")
|
||||
const { structures } = require("../../../tests")
|
||||
const { getDB } = require("../db")
|
||||
|
||||
describe("db", () => {
|
||||
describe("getDB", () => {
|
||||
it("returns a db", async () => {
|
||||
const dbName = structures.db.id()
|
||||
const db = getDB(dbName)
|
||||
expect(db).toBeDefined()
|
||||
expect(db.name).toBe(dbName)
|
||||
})
|
||||
|
||||
it("uses the custom put function", async () => {
|
||||
const db = getDB(structures.db.id())
|
||||
let doc = { _id: "test" }
|
||||
await db.put(doc)
|
||||
doc = await db.get(doc._id)
|
||||
expect(doc.createdAt).toBe(new Date().toISOString())
|
||||
expect(doc.updatedAt).toBe(new Date().toISOString())
|
||||
await db.destroy()
|
||||
})
|
||||
})
|
||||
})
|
|
@ -0,0 +1,32 @@
|
|||
import { context } from "../.."
|
||||
import { structures } from "../../../tests"
|
||||
import { getDB } from "../db"
|
||||
|
||||
interface Doc {
|
||||
_id: string
|
||||
createdAt?: string
|
||||
updatedAt?: string
|
||||
}
|
||||
|
||||
describe("db", () => {
|
||||
describe("getDB", () => {
|
||||
it("returns a db", async () => {
|
||||
const dbName = structures.db.id()
|
||||
const db = getDB(dbName)
|
||||
expect(db).toBeDefined()
|
||||
expect(db.name).toBe(dbName)
|
||||
})
|
||||
|
||||
it("uses the custom put function", async () => {
|
||||
await context.doInTenant("foo", async () => {
|
||||
const db = getDB(structures.db.id())
|
||||
let doc: Doc = { _id: "test" }
|
||||
await db.put(doc)
|
||||
doc = await db.get(doc._id)
|
||||
expect(doc.createdAt).toBe(new Date().toISOString())
|
||||
expect(doc.updatedAt).toBe(new Date().toISOString())
|
||||
await db.destroy()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
|
@ -147,13 +147,13 @@ describe("feature flags", () => {
|
|||
}) => {
|
||||
const env: Partial<typeof environment> = {
|
||||
TENANT_FEATURE_FLAGS: environmentFlags,
|
||||
SELF_HOSTED: false,
|
||||
}
|
||||
|
||||
if (posthogFlags) {
|
||||
mockPosthogFlags(posthogFlags)
|
||||
env.POSTHOG_TOKEN = "test"
|
||||
env.POSTHOG_API_HOST = "https://us.i.posthog.com"
|
||||
env.POSTHOG_PERSONAL_TOKEN = "test"
|
||||
}
|
||||
|
||||
const ctx = { user: { license: { features: licenseFlags || [] } } }
|
||||
|
|
Loading…
Reference in New Issue