feat: publish av-tools 0.1.0
This commit is contained in:
49
tests/unit/derived-cache.test.ts
Normal file
49
tests/unit/derived-cache.test.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
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();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user