Files
openclaw/packages/markdown-core/src/ir.table-code.test.ts
Vincent Koc b015925bc3 test(core): remove dead and duplicate coverage (#116641)
* test(markdown): make code table style coverage assertive

* test(core): remove duplicate regression coverage
2026-07-31 11:48:46 +08:00

69 lines
1.5 KiB
TypeScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Markdown Core tests cover ir.table code behavior.
import { describe, expect, it } from "vitest";
import { markdownToIR } from "./ir.js";
describe("markdownToIR tableMode code", () => {
it("aligns CJK and emoji cells by display width", () => {
const md = `
| Kind | Value |
| --- | --- |
| 类型 | Frontend |
| 👨‍👩‍👧‍👦 | Family |
`.trim();
const ir = markdownToIR(md, { tableMode: "code" });
expect(ir.text).toBe(
[
"| Kind | Value |",
"| ---- | -------- |",
"| 类型 | Frontend |",
"| 👨‍👩‍👧‍👦 | Family |",
"",
].join("\n"),
);
});
it("keeps text-presentation and incomplete emoji sequences narrow", () => {
const md = `
| I | L |
| --- | --- |
| © | text |
| 1 | selector |
| A | ascii |
`.trim();
const ir = markdownToIR(md, { tableMode: "code" });
expect(ir.text).toBe(
[
"| I | L |",
"| --- | -------- |",
"| © | text |",
"| 1 | selector |",
"| A | ascii |",
"",
].join("\n"),
);
});
it("strips inner styles from code-mode table cells", () => {
const md = `
| Name | Value |
|------|-------|
| **Bold** | *Italic* |
| \`Code\` | ~~Strike~~ |
`.trim();
const ir = markdownToIR(md, { tableMode: "code" });
expect(ir.styles).toEqual([
{
start: 0,
end: ir.text.trimEnd().length + 1,
style: "code_block",
},
]);
});
});