镜像自地址
https://github.com/lhly/cloud-drive-renamer.git
已同步 2026-10-20 13:47:47 +08:00
test: 添加清单文件平台匹配单元测试
这个提交包含在:
父节点
99e4444e1d
当前提交
cb32e8aa55
@ -0,0 +1,36 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { resolve } from 'node:path';
|
||||
|
||||
interface ManifestContentScript {
|
||||
matches?: string[];
|
||||
}
|
||||
|
||||
interface ManifestWebAccessibleResource {
|
||||
matches?: string[];
|
||||
}
|
||||
|
||||
interface ExtensionManifest {
|
||||
host_permissions?: string[];
|
||||
content_scripts?: ManifestContentScript[];
|
||||
web_accessible_resources?: ManifestWebAccessibleResource[];
|
||||
}
|
||||
|
||||
function loadManifest(): ExtensionManifest {
|
||||
return JSON.parse(readFileSync(resolve(process.cwd(), 'manifest.json'), 'utf-8')) as ExtensionManifest;
|
||||
}
|
||||
|
||||
describe('manifest platform matches', () => {
|
||||
it('injects 123Pan UI only on yun.123pan.cn', () => {
|
||||
const manifest = loadManifest();
|
||||
const contentScriptMatches = manifest.content_scripts?.flatMap((script) => script.matches ?? []) ?? [];
|
||||
const webAccessibleMatches = manifest.web_accessible_resources?.flatMap((resource) => resource.matches ?? []) ?? [];
|
||||
|
||||
expect(manifest.host_permissions).toContain('https://yun.123pan.cn/*');
|
||||
expect(manifest.host_permissions).not.toContain('https://www.123pan.com/*');
|
||||
expect(contentScriptMatches).toContain('https://yun.123pan.cn/*');
|
||||
expect(contentScriptMatches).not.toContain('https://www.123pan.com/*');
|
||||
expect(webAccessibleMatches).toContain('https://yun.123pan.cn/*');
|
||||
expect(webAccessibleMatches).not.toContain('https://www.123pan.com/*');
|
||||
});
|
||||
});
|
||||
正在加载...
在新工单中引用
屏蔽一个用户