cloud-drive-renamer/tests/unit/adapters/onedrive-name-validation.test.ts
Zain 1176d08224 feat(onedrive): 新增 OneDrive 个人版支持,更新第 13 个平台文案与键盘隔离
新增 OneDrive 个人版适配器、MAIN 桥接、名称校验与冲突检测、目录身份与分页遍历。同步更新三语简介、商店素材、仓库描述及
manifest 域名注册。修复面板键盘冒泡至宿主页面的隔离与工具栏 Escape 作用域。修正 OneDrive 同步结果语义为手动刷新提示,
避免误报同步失败。补全对应单测与浏览器验收脚本。
2026-09-27 17:31:44 +08:00

18 行
909 B
TypeScript

import { describe, expect, it } from 'vitest';
import { validateOneDriveName } from '../../../src/adapters/onedrive/adapter';
describe('OneDrive name validation', () => {
it('accepts ordinary Unicode names and measures characters rather than UTF-8 bytes', () => {
expect(() => validateOneDriveName(`${'中'.repeat(250)}.txt`, 20)).not.toThrow();
});
it('rejects OneDrive-invalid whitespace, characters, reserved names and excessive paths', () => {
expect(() => validateOneDriveName('file.lock')).not.toThrow();
for (const name of ['', ' ', ' leading.txt', 'trailing .txt ', 'name.', 'bad/name', 'CON.txt', 'desktop.ini', '.lock', '~$draft.docx', 'x_vti_y.txt']) {
expect(() => validateOneDriveName(name)).toThrow();
}
expect(() => validateOneDriveName('a'.repeat(256))).toThrow(/long/i);
expect(() => validateOneDriveName('中文.txt', 398)).toThrow(/path/i);
});
});