Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

ChatMarkdown.test.tsx

36 lines1.4 KB

1import { describe, expect, it } from "vite-plus/test";
2​
3import { orderedListGutterStyle } from "./ChatMarkdown";
4​
5describe("orderedListGutterStyle", () => {
6 it("leaves the default gutter alone for single-digit lists", () => {
7 expect(orderedListGutterStyle(9, undefined)).toBeUndefined();
8 });
9​
10 it("leaves the default gutter alone for two-digit lists", () => {
11 expect(orderedListGutterStyle(99, undefined)).toBeUndefined();
12 });
13​
14 it("leaves the default gutter alone for a two-digit list that starts above 1", () => {
15 // start=50 + 49 items => last marker is "98", still two digits.
16 expect(orderedListGutterStyle(49, 50)).toBeUndefined();
17 });
18​
19 it("widens the gutter once the last marker reaches three digits", () => {
20 // item 100 is the bug from #6512: a 100-item list starting at 1.
21 expect(orderedListGutterStyle(100, undefined)).toEqual({ "--list-gutter": "4ch" });
22 });
23​
24 it("accounts for a non-default start attribute", () => {
25 // start=95 + 9 items => last marker is "103", three digits.
26 expect(orderedListGutterStyle(9, 95)).toEqual({ "--list-gutter": "4ch" });
27 });
28​
29 it("scales further for four-digit markers", () => {
30 expect(orderedListGutterStyle(1000, undefined)).toEqual({ "--list-gutter": "5ch" });
31 });
32​
33 it("treats a missing/zero item count as a single item", () => {
34 expect(orderedListGutterStyle(0, undefined)).toBeUndefined();
35 });
36});