20 lines
891 B
TypeScript
20 lines
891 B
TypeScript
// @vitest-environment node
|
|
import { describe, expect, test } from "vitest";
|
|
import { readFileSync } from "node:fs";
|
|
import { fileURLToPath } from "node:url";
|
|
import path from "node:path";
|
|
|
|
const source = readFileSync(path.join(path.dirname(fileURLToPath(import.meta.url)), "entityViews.db.server.ts"), "utf8");
|
|
|
|
describe("entity views db wrapper", () => {
|
|
test("does not include tenant user-private views unless a user id is explicit", () => {
|
|
expect(source).toContain("const userId = options.userId ?? null");
|
|
expect(source).toContain("if (userId) {\n scope.unshift({ tenantId: options.tenantId, userId });\n }");
|
|
});
|
|
|
|
test("supports scoped entity-view lookup by id", () => {
|
|
expect(source).toContain("entityId: options?.entityId");
|
|
expect(source).toContain("...buildEntityViewScopeWhere({ tenantId: options?.tenantId, userId: options?.userId })");
|
|
});
|
|
});
|