43 lines
1.3 KiB
TypeScript
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,
|
||
|
|
);
|
||
|
|
});
|
||
|
|
});
|