@adonis-agora/media
Version:
Media-library for AdonisJS — owner collections (MIME whitelist, single-file replace, ordering), image conversions (eager/lazy), pluggable content transformers (HLS video via mediabunny, metadata probe, image blur-up placeholder), and column attachments, a
21 lines • 878 B
JavaScript
const CONTENT_TYPE = {
jpeg: 'image/jpeg',
png: 'image/png',
webp: 'image/webp',
avif: 'image/avif',
};
/**
* Deterministic {@link ImageProcessor} for tests — never touches sharp. It records every call and
* returns a tiny synthetic buffer tagged with the preset, so conversion paths and lazy/eager
* behaviour can be asserted without real image decoding.
*/
export class FakeImageProcessor {
calls = [];
async convert(input, preset, options) {
this.calls.push({ inputSize: input.byteLength, preset, ...(options ? { options } : {}) });
const format = preset.format ?? 'webp';
const data = Buffer.from(`fake:${preset.name}:${preset.width ?? ''}x${preset.height ?? ''}`);
return { data, format, contentType: CONTENT_TYPE[format] ?? 'application/octet-stream' };
}
}
//# sourceMappingURL=fake_image_processor.js.map