UNPKG

@bigdigital/kiosk-content-sdk

Version:

A Firebase-powered Content Management System SDK optimized for kiosks with offline support, template management, and real-time connection monitoring

102 lines 3.65 kB
import { describe, it, expect } from '@jest/globals'; import { contentSchema, templateSchema, normalizeGroupName } from "../types"; describe("Content Schema Validation", () => { it("should validate content without the content field", () => { const validContent = { id: "test-1", title: "Test Content", description: "Test Description", type: "template", status: "draft", projectIds: ["project-1"], createdBy: "user-1", createdAt: Date.now(), updatedAt: Date.now(), published: true, templateId: "template-1", templateValues: { groups: { basicInfo: { name: "Test Name" } }, ungrouped: {} }, metadata: {} }; const result = contentSchema.safeParse(validContent); expect(result.success).toBe(true); }); it("should handle the new status field correctly", () => { const content = { id: "test-1", title: "Test Content", description: "Test Description", type: "template", status: "published", projectIds: ["project-1"], createdBy: "user-1", createdAt: Date.now(), updatedAt: Date.now(), templateId: "template-1", metadata: {} }; const result = contentSchema.safeParse(content); expect(result.success).toBe(true); if (result.success) { expect(result.data.status).toBe("published"); } }); it("should normalize group names in template values", () => { const template = { id: "template-1", name: "Test Template", description: "Test Description", type: "content", fields: { "field-1": { id: "field-1", name: "testField", label: "Test Field", type: "text" } }, groups: { "group-1": { id: "group-1", name: "Basic Info", description: "Basic Information", order: 0, fieldIds: ["field-1"], displayName: "Basic Info", normalizedName: "basicInfo" } }, ungroupedFieldIds: [], groupOrder: ["group-1"], createdBy: "user-1", createdAt: Date.now(), updatedAt: Date.now(), version: 1 }; const result = templateSchema.safeParse(template); expect(result.success).toBe(true); if (result.success) { const group = result.data.groups["group-1"]; expect(group.normalizedName).toBe("basicInfo"); } }); it("should properly normalize various group name formats", () => { const testCases = [ { input: "Basic Info", expected: "basicInfo" }, { input: "call-to-action", expected: "callToAction" }, { input: "USER_PROFILE", expected: "userProfile" }, { input: "productDetails123", expected: "productDetails123" }, { input: "API Configuration", expected: "apiConfiguration" } ]; testCases.forEach(({ input, expected }) => { expect(normalizeGroupName(input)).toBe(expected); }); }); }); //# sourceMappingURL=schema.test.js.map