master @ 26 LINES
[ HISTORY ] [ UP ]
┌─ TS ───────────────────────────────────────────────────────────────────────┐
│ import { describe, expect, it } from "vitest"; │
│ import { NAV_GAP, NAV_ITEMS, NAV_LANG_W, itemsWidth, navRows } from "./NavBar"; │
│ import { MOBILE_FRAME_W, FRAME_W } from "../../lib/config"; │
│ │
│ describe("navRows", () => { │
│ it("keeps every item on one row at desktop width", () => { │
│ const rows = navRows(NAV_ITEMS, FRAME_W, NAV_GAP, NAV_LANG_W + 1); │
│ expect(rows).toHaveLength(1); │
│ }); │
│ │
│ it("wraps when items exceed the width", () => { │
│ const many = [...NAV_ITEMS, ...NAV_ITEMS, ...NAV_ITEMS]; │
│ const rows = navRows(many, MOBILE_FRAME_W, 1); │
│ expect(rows.length).toBeGreaterThan(1); │
│ for (const row of rows) { │
│ expect(itemsWidth(row, 1)).toBeLessThanOrEqual(MOBILE_FRAME_W); │
│ } │
│ }); │
│ │
│ it("preserves item order across rows", () => { │
│ const many = [...NAV_ITEMS, ...NAV_ITEMS]; │
│ const rows = navRows(many, MOBILE_FRAME_W, 1); │
│ expect(rows.flat().map((it) => it.label)).toEqual(many.map((it) => it.label)); │
│ }); │
│ }); │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ TS ─────────────────────────────────┐
│ import { describe, expect, it } from "vitest │
│ "; │
│ import { NAV_GAP, NAV_ITEMS, NAV_LANG_W, ite │
│ msWidth, navRows } from "./NavBar"; │
│ import { MOBILE_FRAME_W, FRAME_W } from "../ │
│ ../lib/config"; │
│ │
│ describe("navRows", () => { │
│ it("keeps every item on one row at desktop │
│ width", () => { │
│ const rows = navRows(NAV_ITEMS, FRAME_W, │
│ NAV_GAP, NAV_LANG_W + 1); │
│ expect(rows).toHaveLength(1); │
│ }); │
│ │
│ it("wraps when items exceed the width", () │
│ => { │
│ const many = [...NAV_ITEMS, ...NAV_ITEMS │
│ , ...NAV_ITEMS]; │
│ const rows = navRows(many, MOBILE_FRAME_ │
│ W, 1); │
│ expect(rows.length).toBeGreaterThan(1); │
│ for (const row of rows) { │
│ expect(itemsWidth(row, 1)).toBeLessTha │
│ nOrEqual(MOBILE_FRAME_W); │
│ } │
│ }); │
│ │
│ it("preserves item order across rows", () │
│ => { │
│ const many = [...NAV_ITEMS, ...NAV_ITEMS │
│ ]; │
│ const rows = navRows(many, MOBILE_FRAME_ │
│ W, 1); │
│ expect(rows.flat().map((it) => it.label) │
│ ).toEqual(many.map((it) => it.label)); │
│ }); │
│ }); │
└──────────────────────────────────────────────┘
──────────────────────────────────────────────────────────────────────────────────────
OOKNET
────────────────────────────────────────────────
OOKNET