mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-03 12:02:53 +00:00
feat(data): add method that checks if data item has been saved
This commit is contained in:
@@ -220,4 +220,10 @@ describe('DataProvider', () => {
|
||||
const result = await storageProvider.getAll();
|
||||
expect(Array.from(result.keys())).toEqual(['some-uid']);
|
||||
});
|
||||
|
||||
it('should properly check if a data item has already been saved', async () => {
|
||||
expect(await dataProvider.isSaved(sampleThing.uid)).toBeFalsy();
|
||||
await dataProvider.put(sampleThing);
|
||||
expect(await dataProvider.isSaved(sampleThing.uid)).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -147,4 +147,13 @@ export class DataProvider {
|
||||
async search(query: SCSearchQuery): Promise<SCSearchResponse> {
|
||||
return (await this.client.search(query));
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides information if something with an UID is saved as a data item
|
||||
*
|
||||
* @param uid Unique identifier of the saved data item
|
||||
*/
|
||||
async isSaved(uid: string): Promise<boolean> {
|
||||
return this.storageProvider.has(this.getDataKey(uid));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user