mirror of
https://github.com/TextPlace/CoreTextPlace.git
synced 2025-12-16 04:12:35 +00:00
Replace Deno configs and workflows with pnpm/Node tooling Add package.json, jsr.json, build.config.ts and pnpm-lock.yaml Remove deno.json, deno.lock, Deno build scripts and workflow Move source files into src/ and update imports and tests to vitest Add Test CI workflow and adapt publish jobs for pnpm/node Update editor settings, tasks, .gitignore and bump LICENSE year
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
import { it, expect } from "vitest";
|
||
|
||
import { getCharacterWidth } from "../src/mod.ts";
|
||
|
||
it("getCharacterWidth ASCII", () => {
|
||
expect(getCharacterWidth("a")).toBe(1);
|
||
expect(getCharacterWidth("A")).toBe(1);
|
||
expect(getCharacterWidth("1")).toBe(1);
|
||
expect(getCharacterWidth("@")).toBe(1);
|
||
expect(getCharacterWidth(" ")).toBe(1);
|
||
|
||
expect(() => getCharacterWidth("")).toThrow();
|
||
expect(() => getCharacterWidth("ab")).toThrow();
|
||
});
|
||
|
||
it("getCharacterWidth CJK", () => {
|
||
expect(getCharacterWidth("你")).toBe(2);
|
||
expect(getCharacterWidth("好")).toBe(2);
|
||
expect(getCharacterWidth("吗")).toBe(2);
|
||
|
||
expect(getCharacterWidth("ガ")).toBe(2);
|
||
expect(getCharacterWidth("ギ")).toBe(2);
|
||
expect(getCharacterWidth("グ")).toBe(2);
|
||
expect(getCharacterWidth("ソ")).toBe(2);
|
||
|
||
expect(getCharacterWidth("?")).toBe(2);
|
||
expect(getCharacterWidth("!")).toBe(2);
|
||
expect(() => getCharacterWidth("你好")).toThrow();
|
||
expect(() => getCharacterWidth("ヨスガノ")).toThrow();
|
||
});
|
||
|
||
it("getCharacterWidth Emoji", () => {
|
||
expect(getCharacterWidth("👋")).toBe(2);
|
||
expect(getCharacterWidth("🌲️")).toBe(2);
|
||
expect(getCharacterWidth("👨👩👧👦")).toBe(2);
|
||
});
|
||
|
||
it("getCharacterWidth previously faulty cases", () => {
|
||
expect(getCharacterWidth("𤲶")).toBe(2);
|
||
});
|