mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
feat: Update ExtensionBasedMapper custom types
This commit is contained in:
committed by
Joachim Van Herwegen
parent
c01e33ecd9
commit
3f8f822d81
@@ -130,6 +130,28 @@ describe('An ExtensionBasedMapper', (): void => {
|
||||
await expect(result).rejects.toThrow(NotImplementedHttpError);
|
||||
await expect(result).rejects.toThrow('Unsupported content type fake/data');
|
||||
});
|
||||
|
||||
it('supports custom types.', async(): Promise<void> => {
|
||||
const customMapper = new ExtensionBasedMapper(base, rootFilepath, { cstm: 'text/custom' });
|
||||
await expect(customMapper.mapUrlToFilePath({ path: `${base}test.cstm` }, false))
|
||||
.resolves.toEqual({
|
||||
identifier: { path: `${base}test.cstm` },
|
||||
filePath: `${rootFilepath}test.cstm`,
|
||||
contentType: 'text/custom',
|
||||
isMetadata: false,
|
||||
});
|
||||
});
|
||||
|
||||
it('supports custom extensions.', async(): Promise<void> => {
|
||||
const customMapper = new ExtensionBasedMapper(base, rootFilepath, { cstm: 'text/custom' });
|
||||
await expect(customMapper.mapUrlToFilePath({ path: `${base}test` }, false, 'text/custom'))
|
||||
.resolves.toEqual({
|
||||
identifier: { path: `${base}test` },
|
||||
filePath: `${rootFilepath}test$.cstm`,
|
||||
contentType: 'text/custom',
|
||||
isMetadata: false,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('mapFilePathToUrl', (): void => {
|
||||
@@ -180,6 +202,17 @@ describe('An ExtensionBasedMapper', (): void => {
|
||||
isMetadata: false,
|
||||
});
|
||||
});
|
||||
|
||||
it('supports custom extensions.', async(): Promise<void> => {
|
||||
const customMapper = new ExtensionBasedMapper(base, rootFilepath, { cstm: 'text/custom' });
|
||||
await expect(customMapper.mapFilePathToUrl(`${rootFilepath}test$.cstm`, false))
|
||||
.resolves.toEqual({
|
||||
identifier: { path: `${base}test` },
|
||||
filePath: `${rootFilepath}test$.cstm`,
|
||||
contentType: 'text/custom',
|
||||
isMetadata: false,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('An ExtensionBasedMapperFactory', (): void => {
|
||||
|
||||
Reference in New Issue
Block a user