mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
refactor: Make ExtensionBasedMapper only expose what is needed
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import fs from 'fs';
|
||||
import { ExtensionBasedMapper } from '../../../src/storage/ExtensionBasedMapper';
|
||||
import { ConflictHttpError } from '../../../src/util/errors/ConflictHttpError';
|
||||
import { NotFoundHttpError } from '../../../src/util/errors/NotFoundHttpError';
|
||||
import { UnsupportedHttpError } from '../../../src/util/errors/UnsupportedHttpError';
|
||||
import { trimTrailingSlashes } from '../../../src/util/Util';
|
||||
@@ -136,22 +135,4 @@ describe('An ExtensionBasedMapper', (): void => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('extractDocumentName', (): void => {
|
||||
it('throws an error if the input corresponds to root.', async(): Promise<void> => {
|
||||
expect((): any => mapper.extractDocumentName({ path: base })).toThrow(ConflictHttpError);
|
||||
expect((): any => mapper.extractDocumentName({ path: trimTrailingSlashes(base) }))
|
||||
.toThrow(ConflictHttpError);
|
||||
});
|
||||
|
||||
it('parses the identifier into container file path and document name.', async(): Promise<void> => {
|
||||
expect(mapper.extractDocumentName({ path: `${base}test` })).toEqual({
|
||||
containerPath: rootFilepath,
|
||||
documentName: 'test',
|
||||
});
|
||||
expect(mapper.extractDocumentName({ path: `${base}test/` })).toEqual({
|
||||
containerPath: `${rootFilepath}test/`,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user