feat: file-based backend fallback for unknown media types

This commit is contained in:
Wannes Kerckhove
2022-04-25 15:58:58 +02:00
committed by Joachim Van Herwegen
parent fa78bc6856
commit ff80079000
6 changed files with 70 additions and 16 deletions

View File

@@ -125,11 +125,16 @@ describe('An ExtensionBasedMapper', (): void => {
});
});
it('throws 501 if the given content-type is not recognized.', async(): Promise<void> => {
const result = mapper.mapUrlToFilePath({ path: `${base}test.txt` }, false, 'fake/data');
await expect(result).rejects.toThrow(NotImplementedHttpError);
await expect(result).rejects.toThrow('Unsupported content type fake/data');
});
it('falls back to custom extension for unknown types (for which no custom mapping exists).',
async(): Promise<void> => {
const result = mapper.mapUrlToFilePath({ path: `${base}test` }, false, 'unknown/content-type');
await expect(result).resolves.toEqual({
identifier: { path: `${base}test` },
filePath: `${rootFilepath}test$.unknown`,
contentType: undefined,
isMetadata: false,
});
});
it('supports custom types.', async(): Promise<void> => {
const customMapper = new ExtensionBasedMapper(base, rootFilepath, { cstm: 'text/custom' });