feat: publish av-tools 0.1.0
This commit is contained in:
38
tests/unit/ffmpeg-mode.test.ts
Normal file
38
tests/unit/ffmpeg-mode.test.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import {
|
||||
describeEngineMode,
|
||||
selectEngineMode,
|
||||
supportsMultithread,
|
||||
} from '../../src/ffmpeg/engine-mode';
|
||||
import type { EngineEnvironment } from '../../src/ffmpeg/ffmpeg.types';
|
||||
|
||||
const isolated: EngineEnvironment = {
|
||||
secureContext: true,
|
||||
crossOriginIsolated: true,
|
||||
sharedArrayBuffer: true,
|
||||
hardwareConcurrency: 8,
|
||||
};
|
||||
|
||||
describe('engine mode selection', () => {
|
||||
it('selects multithread only when every required capability is present', () => {
|
||||
expect(supportsMultithread(isolated)).toBe(true);
|
||||
expect(selectEngineMode(isolated, 'automatic')).toBe('multithread');
|
||||
|
||||
for (const missing of [
|
||||
'secureContext',
|
||||
'crossOriginIsolated',
|
||||
'sharedArrayBuffer',
|
||||
] as const) {
|
||||
expect(
|
||||
selectEngineMode({ ...isolated, [missing]: false }, 'automatic')
|
||||
).toBe('single-thread');
|
||||
}
|
||||
});
|
||||
|
||||
it('honours the safe single-thread preference', () => {
|
||||
expect(selectEngineMode(isolated, 'force-single-thread')).toBe(
|
||||
'single-thread'
|
||||
);
|
||||
expect(describeEngineMode('single-thread')).toMatch(/compatibility/);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user