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

ThreadGitControls.logic.test.ts

42 lines1.7 KB

1import { expect, it } from "vite-plus/test";
2​
3import { compactMenuBranchLabel } from "./ThreadGitControls.logic";
4​
5it("keeps emoji whole at both cuts of a long branch name", () => {
6 expect(compactMenuBranchLabel("feature/abc😀-long-branch-name-😀-for-menus")).toBe(
7 "feature/abc…-for-menus",
8 );
9});
10​
11it.each([
12 [
13 "ZWJ sequence at the head cut",
14 "a".repeat(10) + "\u{1f469}\u200d\u{1f4bb}" + "z".repeat(20),
15 "aaaaaaaaaa…zzzzzzzzzzz",
16 ],
17 ["skin tone at the tail cut", "a".repeat(20) + "👍🏽" + "z".repeat(9), "aaaaaaaaaaaa…zzzzzzzzz"],
18])("omits a split emoji: %s", (_description, branch, expected) => {
19 expect(compactMenuBranchLabel(branch)).toBe(expected);
20});
21​
22it("keeps flag emoji whole at both cuts of a long branch name", () => {
23 expect(compactMenuBranchLabel("feature/ab🇺🇸-12345678901234567890")).toBe(
24 "feature/ab…01234567890",
25 );
26 expect(compactMenuBranchLabel("feature/12345678901234567890-🇺🇸123456789")).toBe(
27 "feature/1234…123456789",
28 );
29 expect(compactMenuBranchLabel("feature/12345678901234567890-🇺🇸\u{1D165}1234567")).toBe(
30 "feature/1234…1234567",
31 );
32});
33​
34it("keeps combining marks with their letter at both cuts of a long branch name", () => {
35 expect(compactMenuBranchLabel("t3/परीक्षणशाखाबदलावनयापेजसंपादकमनक")).toBe("t3/परीक्षणशा…जसंपादकमनक");
36 expect(compactMenuBranchLabel("t3/abcdefghe\u0301-ijklmnopqrstuvwxyz")).toBe(
37 "t3/abcdefgh…pqrstuvwxyz",
38 );
39 expect(compactMenuBranchLabel("t3/abcdefgha\u0302\u0309\u0301pqrstuvwxy")).toBe(
40 "t3/abcdefgh…pqrstuvwxy",
41 );
42});