Remove remaning faker refs
This commit is contained in:
parent
c7d0a077be
commit
79ee85dab3
|
@ -8,7 +8,7 @@ const {
|
||||||
const { generateAppID, getPlatformUrl, getScopedConfig } = require("../utils")
|
const { generateAppID, getPlatformUrl, getScopedConfig } = require("../utils")
|
||||||
const tenancy = require("../../tenancy")
|
const tenancy = require("../../tenancy")
|
||||||
const { Config, DEFAULT_TENANT_ID } = require("../../constants")
|
const { Config, DEFAULT_TENANT_ID } = require("../../constants")
|
||||||
import { faker } from "@faker-js/faker"
|
import { generator } from "../../../tests"
|
||||||
import env from "../../environment"
|
import env from "../../environment"
|
||||||
|
|
||||||
describe("utils", () => {
|
describe("utils", () => {
|
||||||
|
@ -119,7 +119,7 @@ describe("getPlatformUrl", () => {
|
||||||
|
|
||||||
it("gets the platform url from the database", async () => {
|
it("gets the platform url from the database", async () => {
|
||||||
await tenancy.doInTenant(null, async () => {
|
await tenancy.doInTenant(null, async () => {
|
||||||
const dbUrl = faker.internet.url()
|
const dbUrl = generator.url()
|
||||||
await setDbPlatformUrl(dbUrl)
|
await setDbPlatformUrl(dbUrl)
|
||||||
const url = await getPlatformUrl()
|
const url = await getPlatformUrl()
|
||||||
expect(url).toBe(dbUrl)
|
expect(url).toBe(dbUrl)
|
||||||
|
@ -153,7 +153,7 @@ describe("getPlatformUrl", () => {
|
||||||
|
|
||||||
it("never gets the platform url from the database", async () => {
|
it("never gets the platform url from the database", async () => {
|
||||||
await tenancy.doInTenant(DEFAULT_TENANT_ID, async () => {
|
await tenancy.doInTenant(DEFAULT_TENANT_ID, async () => {
|
||||||
await setDbPlatformUrl(faker.internet.url())
|
await setDbPlatformUrl(generator.url())
|
||||||
const url = await getPlatformUrl()
|
const url = await getPlatformUrl()
|
||||||
expect(url).toBe(TENANT_AWARE_URL)
|
expect(url).toBe(TENANT_AWARE_URL)
|
||||||
})
|
})
|
||||||
|
@ -171,7 +171,7 @@ describe("getScopedConfig", () => {
|
||||||
|
|
||||||
it("returns the platform url with an existing config", async () => {
|
it("returns the platform url with an existing config", async () => {
|
||||||
await tenancy.doInTenant(DEFAULT_TENANT_ID, async () => {
|
await tenancy.doInTenant(DEFAULT_TENANT_ID, async () => {
|
||||||
const dbUrl = faker.internet.url()
|
const dbUrl = generator.url()
|
||||||
await setDbPlatformUrl(dbUrl)
|
await setDbPlatformUrl(dbUrl)
|
||||||
const db = tenancy.getGlobalDB()
|
const db = tenancy.getGlobalDB()
|
||||||
const config = await getScopedConfig(db, { type: Config.SETTINGS })
|
const config = await getScopedConfig(db, { type: Config.SETTINGS })
|
||||||
|
|
|
@ -2,9 +2,8 @@ require("../../../tests")
|
||||||
const { runMigrations, getMigrationsDoc } = require("../index")
|
const { runMigrations, getMigrationsDoc } = require("../index")
|
||||||
const { getGlobalDBName, getDB } = require("../../db")
|
const { getGlobalDBName, getDB } = require("../../db")
|
||||||
|
|
||||||
const { faker } = require( "@faker-js/faker")
|
|
||||||
|
|
||||||
const { default: environment } = require("../../environment")
|
const { default: environment } = require("../../environment")
|
||||||
|
const { newid } = require("../../newid")
|
||||||
environment._set("MULTI_TENANCY", 'TRUE')
|
environment._set("MULTI_TENANCY", 'TRUE')
|
||||||
|
|
||||||
let db
|
let db
|
||||||
|
@ -22,7 +21,7 @@ describe("migrations", () => {
|
||||||
let tenantId
|
let tenantId
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
tenantId =faker.random.alpha(10)
|
tenantId = `tenant_${newid()}`
|
||||||
db = getDB(getGlobalDBName(tenantId))
|
db = getDB(getGlobalDBName(tenantId))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@ import * as events from "../../events"
|
||||||
import * as db from "../../db"
|
import * as db from "../../db"
|
||||||
import { Header } from "../../constants"
|
import { Header } from "../../constants"
|
||||||
import { doInTenant } from "../../context"
|
import { doInTenant } from "../../context"
|
||||||
import { faker } from "@faker-js/faker"
|
|
||||||
import environment from "../../environment"
|
import environment from "../../environment"
|
||||||
|
import { newid } from "../../utils"
|
||||||
|
|
||||||
describe("utils", () => {
|
describe("utils", () => {
|
||||||
describe("platformLogout", () => {
|
describe("platformLogout", () => {
|
||||||
|
@ -14,7 +14,7 @@ describe("utils", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should call platform logout", async () => {
|
it("should call platform logout", async () => {
|
||||||
await doInTenant(faker.random.alpha(10), async () => {
|
await doInTenant(`tenant-${newid()}`, async () => {
|
||||||
const ctx = structures.koa.newContext()
|
const ctx = structures.koa.newContext()
|
||||||
await utils.platformLogout({ ctx, userId: "test" })
|
await utils.platformLogout({ ctx, userId: "test" })
|
||||||
expect(events.auth.logout).toBeCalledTimes(1)
|
expect(events.auth.logout).toBeCalledTimes(1)
|
||||||
|
@ -64,7 +64,7 @@ describe("utils", () => {
|
||||||
const app = structures.apps.app(expected)
|
const app = structures.apps.app(expected)
|
||||||
|
|
||||||
// set custom url
|
// set custom url
|
||||||
const appUrl = faker.datatype.uuid()
|
const appUrl = newid()
|
||||||
app.url = `/${appUrl}`
|
app.url = `/${appUrl}`
|
||||||
ctx.path = `/app/${appUrl}`
|
ctx.path = `/app/${appUrl}`
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue