diff --git a/packages/backend-core/src/context/mainContext.ts b/packages/backend-core/src/context/mainContext.ts index 7e02e60133..550d033073 100644 --- a/packages/backend-core/src/context/mainContext.ts +++ b/packages/backend-core/src/context/mainContext.ts @@ -44,7 +44,7 @@ export function baseGlobalDBName(tenantId: string | undefined | null) { } export function isMultiTenant() { - return env.MULTI_TENANCY + return !!env.MULTI_TENANCY } export function isTenantIdSet() { diff --git a/packages/backend-core/src/tenancy/tests/tenancy.spec.ts b/packages/backend-core/src/tenancy/tests/tenancy.spec.ts index c6f4a9b212..1d98f760c8 100644 --- a/packages/backend-core/src/tenancy/tests/tenancy.spec.ts +++ b/packages/backend-core/src/tenancy/tests/tenancy.spec.ts @@ -5,7 +5,10 @@ jest.mock("../../context", () => ({ })) import { addTenantToUrl } from "../" - +import { isMultiTenant } from "../../context" +const mockedIsMultiTenant = isMultiTenant as jest.MockedFunction< + typeof isMultiTenant +> describe("addTenantToUrl", () => { it("should append tenantId parameter to the URL", () => { const url = "https://budibase.com" @@ -21,9 +24,8 @@ describe("addTenantToUrl", () => { it("should not append tenantId parameter to the URL if isMultiTenant is false", () => { // mock the `isMultiTenant` function to return false - jest.mock("../../src/context", () => ({ - isMultiTenant: jest.fn(() => false), - })) + + mockedIsMultiTenant.mockImplementation(() => false) const url = "https://budibase.com" const expectedUrl = "https://budibase.com"