relay filter/appview bootstrap
at main 1.0 kB view raw
1import { describe, it, expect } from "bun:test"; 2import { parseLimit } from "../../src/util/params"; 3 4describe("parseLimit", () => { 5 it("should return the default limit when input is undefined", () => { 6 expect(parseLimit(undefined)).toBe(50); 7 }); 8 9 it("should return the default limit when input is null", () => { 10 expect(parseLimit(null)).toBe(50); 11 }); 12 13 it("should parse a valid string number", () => { 14 expect(parseLimit("10")).toBe(10); 15 }); 16 17 it("should return the number when input is a number", () => { 18 expect(parseLimit(20)).toBe(20); 19 }); 20 21 it("should return default limit for invalid strings", () => { 22 expect(parseLimit("abc")).toBe(50); 23 }); 24 25 it("should return default limit for negative numbers", () => { 26 expect(parseLimit(-5)).toBe(50); 27 }); 28 29 it("should return default limit for zero", () => { 30 expect(parseLimit(0)).toBe(50); 31 }); 32 33 it("should accept a custom default limit", () => { 34 expect(parseLimit(undefined, 100)).toBe(100); 35 }); 36});