tab-width.test.ts 903 B

1234567891011121314151617181920212223
  1. import assert from "node:assert";
  2. import { describe, it } from "node:test";
  3. import { extractSegments, sliceWithWidth, visibleWidth } from "../src/utils.ts";
  4. describe("tab width accounting", () => {
  5. it("keeps slice helper widths consistent with visible width", () => {
  6. const text = "out 192M\t.pi/skill-tests/results-ha";
  7. const slice = sliceWithWidth(text, 0, 10, true);
  8. assert.strictEqual(slice.text, "out 192M");
  9. assert.strictEqual(slice.width, 8);
  10. assert.strictEqual(visibleWidth(slice.text), slice.width);
  11. });
  12. it("keeps overlay segment widths consistent with visible width", () => {
  13. const text = "out 192M\t.pi/skill-tests/results-ha";
  14. const segments = extractSegments(text, 10, 13, 10, true);
  15. assert.strictEqual(segments.before, "out 192M\t");
  16. assert.strictEqual(segments.beforeWidth, 11);
  17. assert.strictEqual(visibleWidth(segments.before), segments.beforeWidth);
  18. });
  19. });