@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 71 lines 3.01 KB
Raw
1 import { describe, expect, it } from "vite-plus/test";
2 import { markdownWithTextDirection } from "./markdownDocument";
3
4 const LRM = "‎";
5 const RLM = "‏";
6
7 describe("markdownWithTextDirection", () => {
8 it("marks Arabic list items that open with an English name", () => {
9 const markdown = [
10 "## للنمو والتقوية",
11 "",
12 "- **Plantur**، Haarserum 100 مل، 14,95 €. سيروم مخصص للشعر الطويل بالكافيين، أغلى واحد في القائمة.",
13 "- **Bali Curls**، زيت إكليل الجبل للفروة والشعر، موجه للشعر اللي بيخف.",
14 ].join("\n");
15
16 expect(markdownWithTextDirection(markdown)).toBe(
17 [
18 "## للنمو والتقوية",
19 "",
20 `- **${RLM}Plantur**، Haarserum 100 مل، 14,95 €. سيروم مخصص للشعر الطويل بالكافيين، أغلى واحد في القائمة.`,
21 `- **${RLM}Bali Curls**، زيت إكليل الجبل للفروة والشعر، موجه للشعر اللي بيخف.`,
22 ].join("\n"),
23 );
24 });
25
26 it("keeps an English list on one side when one item opens in Arabic", () => {
27 const markdown = "- Install the package first.\n- مرحبا then run the build and tests.";
28 expect(markdownWithTextDirection(markdown)).toBe(
29 `- Install the package first.\n- ${LRM}مرحبا then run the build and tests.`,
30 );
31 });
32
33 it("skips code and keeps task list checkboxes intact", () => {
34 const markdown = "```\nconst a = 'مرحبا';\n```\n\n- [ ] npm تشغيل الأوامر من المجلد الرئيسي";
35 expect(markdownWithTextDirection(markdown)).toBe(
36 `\`\`\`\nconst a = 'مرحبا';\n\`\`\`\n\n- [ ] ${RLM}npm تشغيل الأوامر من المجلد الرئيسي`,
37 );
38 });
39
40 it("keeps words apart across table cells", () => {
41 const markdown = "| Name | الاسم | الوصف |\n| --- | --- | --- |\n| Price | السعر | القيمة |";
42 expect(markdownWithTextDirection(markdown)).toBe(
43 `| ${RLM}Name | الاسم | الوصف |\n| --- | --- | --- |\n| ${RLM}Price | السعر | القيمة |`,
44 );
45 });
46
47 it("puts the mark before a link so references and autolinks still parse", () => {
48 const markdown = [
49 "[Plantur] هذا شرح عربي طويل للمنتج",
50 "",
51 "<https://example.com> هذا شرح عربي طويل للرابط",
52 "",
53 "[Plantur]: /product",
54 ].join("\n");
55 expect(markdownWithTextDirection(markdown)).toBe(
56 [
57 `${RLM}[Plantur] هذا شرح عربي طويل للمنتج`,
58 "",
59 `${RLM}<https://example.com> هذا شرح عربي طويل للرابط`,
60 "",
61 "[Plantur]: /product",
62 ].join("\n"),
63 );
64 });
65
66 it("marks Arabic paragraphs that open with inline code", () => {
67 expect(markdownWithTextDirection("`npm` تشغيل الأوامر من المجلد الرئيسي")).toBe(
68 `${RLM}\`npm\` تشغيل الأوامر من المجلد الرئيسي`,
69 );
70 });
71 });