Port the explorer shell: tokens, header, hero, and a generic table.
CONTENT-WP-0002-T01 adapts the pinned OnCo visual system under ui/ without the corpus, mark, or kind routes. Assistant: grok Assistant-Session: 01a1346c-fdff-7741-b1af-b7283661554b
This commit is contained in:
parent
695060e38d
commit
a6e360aaa5
27 changed files with 4013 additions and 3 deletions
23
ui/lib/sort-rows.test.ts
Normal file
23
ui/lib/sort-rows.test.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import { describe, expect, it } from "vitest";
|
||||
import { nextSort, sortRows } from "./sort-rows";
|
||||
|
||||
const rows = [
|
||||
{ title: "Emergence" },
|
||||
{ title: "Feedback" },
|
||||
{ title: "Requisite variety" },
|
||||
];
|
||||
|
||||
describe("sortRows", () => {
|
||||
it("orders by the selected key and flips with the direction", () => {
|
||||
const ascending = sortRows(rows, { key: "title", dir: 1 }, (row, key) => row[key as "title"]);
|
||||
expect(ascending.map((row) => row.title)).toEqual(["Emergence", "Feedback", "Requisite variety"]);
|
||||
const descending = sortRows(rows, { key: "title", dir: -1 }, (row, key) => row[key as "title"]);
|
||||
expect(descending.map((row) => row.title)).toEqual(["Requisite variety", "Feedback", "Emergence"]);
|
||||
});
|
||||
|
||||
it("toggles direction when the same key is chosen again", () => {
|
||||
expect(nextSort(undefined, "title")).toEqual({ key: "title", dir: 1 });
|
||||
expect(nextSort({ key: "title", dir: 1 }, "title")).toEqual({ key: "title", dir: -1 });
|
||||
expect(nextSort({ key: "title", dir: -1 }, "kindLabel")).toEqual({ key: "kindLabel", dir: 1 });
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue