mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
feat: Added resourceExists method to ResourceStore
* feat: added resourceExists method to ResourceStore * Merge remote-tracking branch 'origin/main' into feat/add-resourceExists-method-to-ResourceStore * fix: adapted to review * fix: adapted to review
This commit is contained in:
committed by
GitHub
parent
e5b7d99da4
commit
b3f292d718
@@ -604,5 +604,28 @@ describe('A DataAccessorBasedStore', (): void => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('resource Exists', (): void => {
|
||||
it('should return false when the resource does not exist.', async(): Promise<void> => {
|
||||
const resourceID = { path: `${root}resource` };
|
||||
await expect(store.resourceExists(resourceID)).resolves.toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return true when the resource exists.', async(): Promise<void> => {
|
||||
const resourceID = { path: `${root}resource` };
|
||||
accessor.data[resourceID.path] = representation;
|
||||
await expect(store.resourceExists(resourceID)).resolves.toBeTruthy();
|
||||
});
|
||||
|
||||
it('should rethrow any unexpected errors from validateIdentifier.', async(): Promise<void> => {
|
||||
const resourceID = { path: `${root}resource` };
|
||||
const originalMetaData = accessor.getMetadata;
|
||||
accessor.getMetadata = jest.fn(async(): Promise<any> => {
|
||||
throw new Error('error');
|
||||
});
|
||||
await expect(store.resourceExists(resourceID)).rejects.toThrow('error');
|
||||
accessor.getMetadata = originalMetaData;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user