返回 oh-my-ppt
resource-policy.test.ts
根目录 / tests / unit / presentation / resource-policy.test.ts
1 import { describe, expect, it } from 'vitest'
2 import { extractRemoteRuntimeResources } from '../../../src/main/presentation/html/resource-policy'
3
4 describe('slide runtime resource policy', () => {
5 it('finds only remote script and stylesheet resources', () => {
6 expect(
7 extractRemoteRuntimeResources(
8 '<script src="https://cdn.example/app.js"></script><link href="//cdn.example/app.css" rel="stylesheet" /><img src="https://cdn.example/image.png" />'
9 )
10 ).toEqual([
11 '<script src="https://cdn.example/app.js">',
12 '<link href="//cdn.example/app.css" rel="stylesheet" />'
13 ])
14 })
15
16 it('caps diagnostic output without rejecting local presentation assets', () => {
17 const remoteScripts = Array.from(
18 { length: 10 },
19 (_, index) => `<script src="https://cdn.example/${index}.js"></script>`
20 ).join('')
21 expect(extractRemoteRuntimeResources('<script src="./assets/ppt-runtime.js"></script>')).toEqual([])
22 expect(extractRemoteRuntimeResources(remoteScripts)).toHaveLength(8)
23 })
24 })
25
25 lines TYPESCRIPT