Skip to content

Commit

Permalink
Add parsePage tests
Browse files Browse the repository at this point in the history
  • Loading branch information
0237h committed Apr 19, 2024
1 parent 563e2ba commit 3a338bf
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/utils.spec.ts
Original file line number Diff line number Diff line change
@@ -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();
});

0 comments on commit 3a338bf

Please sign in to comment.