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 | import { describe, expect, it } from "bun:test"; | |
| import { SQL } from "drizzle-orm"; | |
| import { paginationSchema, paginateDefaults, countSql } from "../pagination"; | |
| describe("paginationSchema", () => { | |
| it("parses valid input with defaults", () => { | |
| const result = paginationSchema.parse({}); | |
| expect(result).toEqual({ limit: 20, offset: 0 }); | |
| }); | |
| it("parses with custom limit and offset", () => { | |
| const result = paginationSchema.parse({ limit: 10, offset: 5 }); | |
| expect(result).toEqual({ limit: 10, offset: 5 }); | |
| }); | |
| it("rejects limit below minimum", () => { | |
| expect(() => paginationSchema.parse({ limit: 0 })).toThrow(); | |
| }); | |
| it("rejects limit above maximum", () => { | |
| expect(() => paginationSchema.parse({ limit: 100 })).toThrow(); | |
| }); | |
| it("rejects negative offset", () => { | |
| expect(() => paginationSchema.parse({ offset: -1 })).toThrow(); | |
| }); | |
| }); | |
| describe("paginateDefaults", () => { | |
| it("returns defaults when input is undefined", () => { | |
| expect(paginateDefaults()).toEqual({ limit: 20, offset: 0 }); | |
| }); | |
| it("returns defaults when input is empty", () => { | |
| expect(paginateDefaults({})).toEqual({ limit: 20, offset: 0 }); | |
| }); | |
| it("uses provided limit", () => { | |
| expect(paginateDefaults({ limit: 5 })).toEqual({ limit: 5, offset: 0 }); | |
| }); | |
| it("uses provided offset", () => { | |
| expect(paginateDefaults({ offset: 10 })).toEqual({ limit: 20, offset: 10 }); | |
| }); | |
| }); | |
| describe("countSql", () => { | |
| it("returns a SQL instance", () => { | |
| const result = countSql("*"); | |
| expect(result).toBeInstanceOf(SQL); | |
| }); | |
| }); | |