Skip to content

Commit 3c870a1

Browse files
norascheuchelenatanasoiu
authored andcommitted
Add test to remove 2 entries from query history
1 parent 2a722ba commit 3c870a1

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

extensions/ql-vscode/src/vscode-tests/no-workspace/remote-queries/variant-analysis-history.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,25 @@ describe('Variant Analyses and QueryHistoryManager', function() {
145145
expect(qhm.treeDataProvider.allHistory).to.deep.eq([rawQueryHistory[1], rawQueryHistory[0]]);
146146
});
147147

148+
it('should remove two queries from history', async () => {
149+
await qhm.readQueryHistory();
150+
151+
// Remove both queries
152+
// Just for fun, let's do it in reverse order
153+
await qhm.handleRemoveHistoryItem(undefined!, [qhm.treeDataProvider.allHistory[1], qhm.treeDataProvider.allHistory[0]]);
154+
155+
expect(removeVariantAnalysisStub.callCount).to.eq(2);
156+
expect(removeVariantAnalysisStub.getCall(0).args[0]).to.eq(rawQueryHistory[1].historyItemId);
157+
expect(removeVariantAnalysisStub.getCall(1).args[0]).to.eq(rawQueryHistory[0].historyItemId);
158+
expect(qhm.treeDataProvider.allHistory).to.deep.eq([]);
159+
160+
// also, both queries should be removed from disk storage
161+
expect(fs.readJSONSync(path.join(STORAGE_DIR, 'workspace-query-history.json'))).to.deep.eq({
162+
version: 2,
163+
queries: []
164+
});
165+
});
166+
148167
async function copyHistoryState() {
149168
fs.ensureDirSync(STORAGE_DIR);
150169
fs.copySync(

0 commit comments

Comments
 (0)