fix: Support entries function in JsonResourceStorage

This commit is contained in:
Joachim Van Herwegen
2022-03-30 16:00:36 +02:00
parent f089ffda47
commit 76548011f2
6 changed files with 192 additions and 61 deletions

View File

@@ -30,4 +30,22 @@ describe('An EncodingPathStorage', (): void => {
await expect(storage.delete(key)).resolves.toBe(true);
expect([ ...map.keys() ]).toHaveLength(0);
});
it('only returns entries from the source storage matching the relative path.', async(): Promise<void> => {
// Base 64 encoding of 'key'
const encodedKey = 'a2V5';
const generatedPath = `${relativePath}${encodedKey}`;
const otherPath = `/otherContainer/${encodedKey}`;
const data = 'data';
map.set(generatedPath, data);
map.set(otherPath, data);
const results = [];
for await (const entry of storage.entries()) {
results.push(entry);
}
expect(results).toHaveLength(1);
expect(results[0]).toEqual([ 'key', data ]);
});
});