Hey is a decentralized and permissionless social media app built with Lens Protocol 🌿

test: cover nFormatter cases (#5973)

authored by yoginth.com and committed by

GitHub 1634b487 a1d01947

+24 -1
+23
apps/web/src/helpers/nFormatter.test.ts
··· 1 + import { describe, expect, it } from "vitest"; 2 + import nFormatter from "./nFormatter"; 3 + 4 + // Tests for nFormatter used in social media contexts 5 + 6 + describe("nFormatter", () => { 7 + it("formats small follower counts", () => { 8 + expect(nFormatter(847)).toBe("847"); 9 + }); 10 + 11 + it("abbreviates thousands with a k", () => { 12 + expect(nFormatter(1520)).toBe("1.5k"); 13 + }); 14 + 15 + it("abbreviates millions with an M", () => { 16 + expect(nFormatter(2300000)).toBe("2.3M"); 17 + }); 18 + 19 + it("returns empty string for invalid counts", () => { 20 + expect(nFormatter(Number.POSITIVE_INFINITY)).toBe(""); 21 + expect(nFormatter(Number.NaN)).toBe(""); 22 + }); 23 + });
+1 -1
apps/web/src/helpers/nFormatter.ts
··· 1 - import humanize from "@/helpers/humanize"; 1 + import humanize from "./humanize"; 2 2 3 3 const LOOKUP = [ 4 4 { symbol: "E", value: 1e18 },