@@ -40,7 +40,7 @@ test("serves the release identity and hardened headers", async ({
|
||||
const manifest = await request.get("/deep/nested/unicode/toolbox-app.json");
|
||||
await expect(manifest.json()).resolves.toMatchObject({
|
||||
id: "de.add-ideas.unicode-tools",
|
||||
version: "0.1.0",
|
||||
version: "0.2.0",
|
||||
entry: "./",
|
||||
});
|
||||
});
|
||||
@@ -59,3 +59,62 @@ test("searches the pinned catalog in a worker and shows character properties", a
|
||||
await expect(page.getByText("Common / Emoticons")).toBeVisible();
|
||||
expect(external).toEqual([]);
|
||||
});
|
||||
|
||||
test("virtualizes a range and labels surrogate code units explicitly", async ({
|
||||
page,
|
||||
}) => {
|
||||
const external = await localOnly(page);
|
||||
await page.goto("/deep/nested/unicode/");
|
||||
await page.getByRole("button", { name: "Code chart" }).click();
|
||||
await page.getByLabel("Range start").fill("U+D7F0");
|
||||
await page.getByLabel("Range end").fill("U+D810");
|
||||
await page.getByRole("button", { name: "Open range" }).click();
|
||||
const surrogate = page.getByRole("gridcell", {
|
||||
name: /U\+D800 UTF-16 SURROGATE CODE UNIT, surrogate/u,
|
||||
});
|
||||
await expect(surrogate).toBeVisible({ timeout: 60_000 });
|
||||
await surrogate.click();
|
||||
await expect(page.getByText(/not a Unicode scalar value/u)).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Copy scalar" }),
|
||||
).toBeDisabled();
|
||||
await surrogate.press("ArrowRight");
|
||||
await expect(
|
||||
page.getByRole("gridcell", { name: /U\+D801 UTF-16 SURROGATE/u }),
|
||||
).toBeFocused();
|
||||
expect(external).toEqual([]);
|
||||
});
|
||||
|
||||
test("inspects graphemes and compares UTS #39 confusable skeletons locally", async ({
|
||||
page,
|
||||
}) => {
|
||||
const external = await localOnly(page);
|
||||
await page.goto("/deep/nested/unicode/");
|
||||
await page.getByRole("button", { name: "Text inspector" }).click();
|
||||
await page.getByLabel("Text to inspect").fill("👨👩👧👦 🇩🇪");
|
||||
await page.getByRole("button", { name: "Inspect text" }).click();
|
||||
await expect(page.getByText("pictographic · ZWJ")).toBeVisible();
|
||||
await expect(page.getByText("2 regional indicator(s)")).toBeVisible();
|
||||
|
||||
await page.getByRole("button", { name: "Normalize & confusables" }).click();
|
||||
const normalization = page
|
||||
.getByRole("heading", {
|
||||
name: "Compare forms and compute a confusable skeleton",
|
||||
})
|
||||
.locator("..");
|
||||
await normalization
|
||||
.getByRole("textbox", { name: "Text", exact: true })
|
||||
.fill("раypal");
|
||||
await normalization
|
||||
.getByRole("textbox", { name: "Compare identifier (optional)" })
|
||||
.fill("paypal");
|
||||
await page.getByRole("button", { name: "Analyze confusables" }).click();
|
||||
await expect(
|
||||
page.getByRole("heading", { name: "UTS #39 confusable analysis" }),
|
||||
).toBeVisible({ timeout: 60_000 });
|
||||
await expect(
|
||||
page.getByText("yes — review", { exact: true }).last(),
|
||||
).toBeVisible();
|
||||
await expect(page.getByText(/mixed-script/u).first()).toBeVisible();
|
||||
expect(external).toEqual([]);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
test("keeps the primary workspace inside a narrow viewport", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto("/deep/nested/unicode/");
|
||||
await expect(page.locator("main").first()).toBeVisible();
|
||||
await expect(
|
||||
page.locator("main .loading, main .workbench-loading"),
|
||||
).toHaveCount(0);
|
||||
|
||||
const widths = await page.evaluate(() => ({
|
||||
content: document.documentElement.scrollWidth,
|
||||
viewport: document.documentElement.clientWidth,
|
||||
}));
|
||||
expect(widths.viewport).toBeLessThanOrEqual(430);
|
||||
expect(widths.content).toBeLessThanOrEqual(widths.viewport + 1);
|
||||
});
|
||||
@@ -1,9 +1,17 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
inspectGraphemeClusters,
|
||||
joinEmojiWithZwj,
|
||||
setEmojiPresentation,
|
||||
setEmojiSkinTone,
|
||||
} from "../../src/unicode/graphemes";
|
||||
import {
|
||||
codePointFallbackStatus,
|
||||
codePointLabel,
|
||||
compareNormalization,
|
||||
decodeCodePointList,
|
||||
inspectText,
|
||||
parseCodeChartRange,
|
||||
parseCodePointList,
|
||||
} from "../../src/unicode/model";
|
||||
|
||||
@@ -26,4 +34,48 @@ describe("Unicode helper integration", () => {
|
||||
expect(result.forms.find((item) => item.form === "NFC")?.value).toBe("é");
|
||||
expect(codePointLabel(0x1f600)).toBe("U+1F600");
|
||||
});
|
||||
|
||||
it("classifies non-character code-space regions explicitly", () => {
|
||||
expect(codePointFallbackStatus(0x0378)).toBe("unassigned");
|
||||
expect(codePointFallbackStatus(0xe000)).toBe("private-use");
|
||||
expect(codePointFallbackStatus(0xd800)).toBe("surrogate");
|
||||
expect(codePointFallbackStatus(0xfdd0)).toBe("noncharacter");
|
||||
expect(codePointFallbackStatus(0x10ffff)).toBe("noncharacter");
|
||||
});
|
||||
|
||||
it("accepts bounded hexadecimal chart ranges", () => {
|
||||
expect(parseCodeChartRange("U+D7F0", "0xE010")).toEqual({
|
||||
start: 0xd7f0,
|
||||
end: 0xe010,
|
||||
});
|
||||
expect(() => parseCodeChartRange("110000", "110001")).toThrow(/U\+10FFFF/u);
|
||||
expect(() => parseCodeChartRange("100", "FF")).toThrow(/must not follow/u);
|
||||
});
|
||||
|
||||
it("reports emoji structure at grapheme-cluster boundaries", () => {
|
||||
const result = inspectGraphemeClusters("👨👩👧👦 🇩🇪 1️⃣");
|
||||
expect(result[0]).toMatchObject({
|
||||
value: "👨👩👧👦",
|
||||
containsZwj: true,
|
||||
extendedPictographic: true,
|
||||
});
|
||||
expect(result.find((item) => item.value === "🇩🇪")?.regionalIndicators).toBe(
|
||||
2,
|
||||
);
|
||||
expect(result.find((item) => item.value === "1️⃣")?.keycap).toBe(true);
|
||||
});
|
||||
|
||||
it("edits bounded emoji sequences without claiming RGI validity", () => {
|
||||
expect(setEmojiPresentation("☕", "emoji")).toBe("☕️");
|
||||
expect(setEmojiSkinTone("👍", 1)).toBe("👍🏻");
|
||||
expect(setEmojiSkinTone("☝️", 1)).toBe("☝🏻");
|
||||
expect(joinEmojiWithZwj(["👩", "💻"])).toBe("👩💻");
|
||||
expect(() => setEmojiPresentation("👩💻", "text")).toThrow(
|
||||
/individual components/u,
|
||||
);
|
||||
expect(() => setEmojiPresentation("👍🏻", "text")).toThrow(
|
||||
/sequence-specific/u,
|
||||
);
|
||||
expect(() => joinEmojiWithZwj(["👩"])).toThrow(/2–8/u);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user