Add test to remove 2 entries from query history

This commit is contained in:
Nora
2022-10-25 14:29:23 +02:00
committed by Elena Tanasoiu
parent 2a722ba264
commit 3c870a10e2

View File

@@ -145,6 +145,25 @@ describe('Variant Analyses and QueryHistoryManager', function() {
expect(qhm.treeDataProvider.allHistory).to.deep.eq([rawQueryHistory[1], rawQueryHistory[0]]);
});
it('should remove two queries from history', async () => {
await qhm.readQueryHistory();
// Remove both queries
// Just for fun, let's do it in reverse order
await qhm.handleRemoveHistoryItem(undefined!, [qhm.treeDataProvider.allHistory[1], qhm.treeDataProvider.allHistory[0]]);
expect(removeVariantAnalysisStub.callCount).to.eq(2);
expect(removeVariantAnalysisStub.getCall(0).args[0]).to.eq(rawQueryHistory[1].historyItemId);
expect(removeVariantAnalysisStub.getCall(1).args[0]).to.eq(rawQueryHistory[0].historyItemId);
expect(qhm.treeDataProvider.allHistory).to.deep.eq([]);
// also, both queries should be removed from disk storage
expect(fs.readJSONSync(path.join(STORAGE_DIR, 'workspace-query-history.json'))).to.deep.eq({
version: 2,
queries: []
});
});
async function copyHistoryState() {
fs.ensureDirSync(STORAGE_DIR);
fs.copySync(