镜像自地址
https://github.com/lhly/cloud-drive-renamer.git
已同步 2026-10-20 21:57:47 +08:00
37 行
1.4 KiB
TypeScript
37 行
1.4 KiB
TypeScript
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/*');
|
|
});
|
|
});
|