cpns / packages /ai /src /__tests__ /errors.test.ts
rogasper's picture
feat: enhance testing capabilities and introduce new components for question management. Add testing section in AGENTS.md with instructions for running tests and configuring the test environment. Update package.json files to include test scripts and integrate @electric-sql/pglite for in-memory database testing. Introduce CalloutCard and update FilterBar and SoalBrowser components to support visibility filters for private and public questions. Implement new test cases for various functionalities across the application.
92a1d83
Raw
History Blame Contribute Delete
889 Bytes
import { describe, expect, it } from "bun:test";
import { GenerationError } from "../errors";
describe("GenerationError", () => {
it("creates error with just a message", () => {
const err = new GenerationError("Something went wrong");
expect(err).toBeInstanceOf(Error);
expect(err.name).toBe("GenerationError");
expect(err.message).toBe("Something went wrong");
expect(err.tokensUsed).toBeUndefined();
expect(err.partialResult).toBeUndefined();
});
it("creates error with tokensUsed", () => {
const err = new GenerationError("Failed", { tokensUsed: 150 });
expect(err.tokensUsed).toBe(150);
});
it("creates error with partialResult", () => {
const partial = { questions: [{ format: "multiple_choice" }] };
const err = new GenerationError("Partial", { partialResult: partial });
expect(err.partialResult).toEqual(partial);
});
});