50 lines
1.2 KiB
TypeScript
50 lines
1.2 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import {
|
|
cacheDerivative,
|
|
readCachedDerivative,
|
|
} from '../../src/app/derived-cache';
|
|
|
|
describe('application derivative cache', () => {
|
|
it('reuses only an exact source and settings identity', async () => {
|
|
const file = new File(['source'], 'preview-source.mp4', {
|
|
type: 'video/mp4',
|
|
lastModified: 123,
|
|
});
|
|
const settings = {
|
|
maxDurationSeconds: 30,
|
|
maxWidth: 960,
|
|
includeAudio: true,
|
|
};
|
|
const derivative = new Blob(['proxy'], { type: 'video/mp4' });
|
|
|
|
await cacheDerivative(
|
|
file,
|
|
'preview-proxy-test',
|
|
'preview-proxy',
|
|
'project-preview-cache-test',
|
|
derivative,
|
|
settings
|
|
);
|
|
|
|
expect(
|
|
await readCachedDerivative(file, 'preview-proxy-test', settings)
|
|
).toEqual(derivative);
|
|
expect(
|
|
await readCachedDerivative(file, 'preview-proxy-test', {
|
|
...settings,
|
|
maxWidth: 1280,
|
|
})
|
|
).toBeUndefined();
|
|
expect(
|
|
await readCachedDerivative(
|
|
new File(['other'], file.name, {
|
|
type: file.type,
|
|
lastModified: file.lastModified,
|
|
}),
|
|
'preview-proxy-test',
|
|
settings
|
|
)
|
|
).toBeUndefined();
|
|
});
|
|
});
|