From 3a338bfd421473c3e287daee6c1a5c11f7881c90 Mon Sep 17 00:00:00 2001 From: Etienne Donneger Date: Fri, 19 Apr 2024 12:05:13 -0400 Subject: [PATCH] Add `parsePage` tests --- src/utils.spec.ts | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/utils.spec.ts b/src/utils.spec.ts index 892f2f1..5b6911d 100644 --- a/src/utils.spec.ts +++ b/src/utils.spec.ts @@ -1,21 +1,27 @@ import { expect, test } from "bun:test"; -import { parseBlockId, parseLimit, parseTimestamp } from "./utils.js"; +import { parseBlockId, parseLimit, parsePage, parseTimestamp } from "./utils.js"; import { config } from "./config.js"; test("parseBlockId", () => { expect(parseBlockId("0x123") as string).toBe("123"); }); -test("parseTimestamp", () => { - expect(parseTimestamp("1697587100")).toBe(1697587100); - expect(parseTimestamp("1697587100000")).toBe(1697587100); - expect(parseTimestamp("awdawd")).toBeNaN(); - expect(parseTimestamp(null)).toBeUndefined(); -}); - test("parseLimit", () => { expect(parseLimit("1")).toBe(1); expect(parseLimit("0")).toBe(1); expect(parseLimit(10)).toBe(10); expect(parseLimit(config.maxLimit + 1)).toBe(config.maxLimit); +}); + +test("parsePage", () => { + expect(parsePage("1")).toBe(1); + expect(parsePage("0")).toBe(1); + expect(parsePage(10)).toBe(10); +}); + +test("parseTimestamp", () => { + expect(parseTimestamp("1697587100")).toBe(1697587100); + expect(parseTimestamp("1697587100000")).toBe(1697587100); + expect(parseTimestamp("awdawd")).toBeNaN(); + expect(parseTimestamp(null)).toBeUndefined(); }); \ No newline at end of file