locale.test.ts 392 B

123456789
  1. import { expect, test } from "bun:test"
  2. import { Locale } from "../../src/util/locale"
  3. test("truncates text from the right by terminal width", () => {
  4. expect(Locale.truncateWidth("abcdefgh", 5)).toBe("abcd…")
  5. expect(Locale.truncateWidth("ab界cd", 5)).toBe("ab界…")
  6. expect(Locale.truncateWidth("abcdefgh", 1)).toBe("…")
  7. expect(Locale.truncateWidth("abcdefgh", 0)).toBe("")
  8. })