beadboard/tests/lib/pathing.test.ts

31 lines
1,021 B
TypeScript
Raw Normal View History

2026-02-11 17:42:51 -08:00
import test from 'node:test';
import assert from 'node:assert/strict';
import {
canonicalizeWindowsPath,
windowsPathKey,
toDisplayPath,
sameWindowsPath,
} from '../../src/lib/pathing';
test('canonicalizeWindowsPath normalizes separators and drive casing', () => {
const input = 'c:/Users/test/project/beadboard/';
2026-02-11 17:42:51 -08:00
const result = canonicalizeWindowsPath(input);
assert.equal(result, 'C:\\Users\\test\\project\\beadboard');
2026-02-11 17:42:51 -08:00
});
test('windowsPathKey is case-insensitive stable key', () => {
const a = windowsPathKey('C:/Users/test/project/beadboard');
const b = windowsPathKey('c:\\users\\test\\project\\beadboard\\');
2026-02-11 17:42:51 -08:00
assert.equal(a, b);
});
test('toDisplayPath renders forward slashes for UI readability', () => {
const display = toDisplayPath('C:\\Users\\test\\project\\beadboard');
assert.equal(display, 'C:/Users/test/project/beadboard');
2026-02-11 17:42:51 -08:00
});
test('sameWindowsPath handles case/separator differences', () => {
assert.equal(sameWindowsPath('D:/Repos/One', 'd:\\repos\\one\\'), true);
2026-03-03 16:43:42 -08:00
});