hivecast-sdk/packages/browser-host/src/__tests__/BundleFreshness.spec.ts
hypnotranz 1a0419dc0c feat: initial Matrix SDK
Full SDK workspace: core, contracts, sdk, cli, browser-host, browser-kit,
federation, omega-core, oracle, self-healing, strategies, tools, emacs.
Clean extraction from the development monorepo.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-07 15:54:15 -06:00

43 lines
1.3 KiB
TypeScript

import { describe, it } from 'node:test';
import { strict as assert } from 'node:assert';
import { htmlReferencesBundle } from '../BundleFreshness';
describe('htmlReferencesBundle', () => {
it('accepts the currently served Vite entry module', () => {
const html = '<script type="module" crossorigin src="/apps/director/assets/index-new.js"></script>';
assert.equal(
htmlReferencesBundle(
html,
'https://dev.hivecast.ai/apps/director/assets/index-new.js',
'https://dev.hivecast.ai/apps/director/',
),
true,
);
});
it('accepts Vite dev HTML that imports the entrypoint from an inline module script', () => {
const html = '<script type="module">import "./index.ts";</script>';
assert.equal(
htmlReferencesBundle(
html,
'https://local.hivecast.ai/apps/web/index.ts',
'https://local.hivecast.ai/apps/web/',
),
true,
);
});
it('rejects an older content-hashed bundle', () => {
const html = '<script type="module" crossorigin src="/apps/director/assets/index-new.js"></script>';
assert.equal(
htmlReferencesBundle(
html,
'https://dev.hivecast.ai/apps/director/assets/index-old.js',
'https://dev.hivecast.ai/apps/director/',
),
false,
);
});
});