GitNexus/gitnexus/test/unit/doctor-format.test.ts

21 lines
771 B
TypeScript

import { describe, expect, it } from 'vitest';
import { displayWidth, padDisplayEnd } from '../../src/cli/doctor.js';
describe('doctor output formatting', () => {
it('keeps ASCII padding equivalent to String.padEnd', () => {
expect(displayWidth('OS:')).toBe(3);
expect(padDisplayEnd('OS:', 10)).toBe('OS:'.padEnd(10));
});
it('pads CJK labels by terminal display width, not code-unit length', () => {
const padded = padDisplayEnd('系统:', 10);
expect(displayWidth('系统:')).toBe(6);
expect(displayWidth(padded)).toBe(10);
expect(padded).toBe('系统: ');
});
it('does not truncate labels that are already wider than the target width', () => {
expect(padDisplayEnd('图存储:', 4)).toBe('图存储:');
});
});