refactor: Make ExtensionBasedMapper only expose what is needed

This commit is contained in:
Joachim Van Herwegen
2020-10-14 16:34:36 +02:00
parent 03c64e5617
commit 4df26454d4
3 changed files with 4 additions and 49 deletions

View File

@@ -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/`,
});
});
});
});