MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / fakeWebAssets

Function fakeWebAssets

apps/kimi-code/test/native/web-assets.test.ts:20–52  ·  view source on GitHub ↗
(files: Record<string, string>)

Source from the content-addressed store, hash-verified

18}
19
20function fakeWebAssets(files: Record<string, string>): {
21 manifest: WebAssetManifest;
22 source: WebAssetSource;
23} {
24 const manifest: WebAssetManifest = {
25 version: WEB_ASSET_MANIFEST_VERSION,
26 target: 'test-target',
27 root: 'dist-web',
28 files: Object.entries(files).map(([relativePath, content]) => ({
29 assetKey: `web/test-target/dist-web/${relativePath}`,
30 relativePath,
31 sha256: sha256(content),
32 })),
33 };
34 const assets = new Map<string, Buffer>([
35 ['web/test-target/manifest.json', Buffer.from(JSON.stringify(manifest))],
36 ...Object.entries(files).map(([relativePath, content]) => [
37 `web/test-target/dist-web/${relativePath}`,
38 Buffer.from(content),
39 ] as const),
40 ]);
41 return {
42 manifest,
43 source: {
44 getAssetKeys: () => [...assets.keys()],
45 getRawAsset: (assetKey) => {
46 const asset = assets.get(assetKey);
47 if (asset === undefined) throw new Error(`missing test asset: ${assetKey}`);
48 return asset;
49 },
50 },
51 };
52}
53
54describe('web assets', () => {
55 it('extracts embedded web assets into a dist-web cache directory', () => {

Callers 1

web-assets.test.tsFile · 0.85

Calls 3

keysMethod · 0.80
sha256Function · 0.70
getMethod · 0.65

Tested by

no test coverage detected