UNPKG

@copilotkit/shared

Version:

<img src="https://github.com/user-attachments/assets/0a6b64d9-e193-4940-a3f6-60334ac34084" alt="banner" style="border-radius: 12px; border: 2px solid #d6d4fa;" />

34 lines (30 loc) 1.12 kB
import { describe, it, expect } from "vitest"; import { createLicenseContextValue } from "../index"; import type { RuntimeLicenseStatus } from "../utils/types"; describe("createLicenseContextValue", () => { it("fails open when no status is known", () => { for (const status of [null, undefined] as const) { const ctx = createLicenseContextValue(status); expect(ctx.status).toBeNull(); expect(ctx.license).toBeNull(); expect(ctx.checkFeature("chat")).toBe(true); expect(ctx.getLimit("chat")).toBeNull(); } }); it.each(["valid", "none", "expiring", "unknown"] as RuntimeLicenseStatus[])( "enables features for %s status", (status) => { const ctx = createLicenseContextValue(status); expect(ctx.status).toBe(status); expect(ctx.checkFeature("chat")).toBe(true); }, ); it.each(["expired", "invalid"] as RuntimeLicenseStatus[])( "disables features for %s status", (status) => { const ctx = createLicenseContextValue(status); expect(ctx.status).toBe(status); expect(ctx.checkFeature("chat")).toBe(false); }, ); });