Skip to content

Commit 2a722ba

Browse files
Add test for removing a variant analysis history item
Co-authored-by: Nora Scheuch <norascheuch@github.com>
1 parent da754a2 commit 2a722ba

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,31 @@ describe('Variant Analyses and QueryHistoryManager', function() {
120120
expect(qhm.treeDataProvider.allHistory.length).to.eq(2);
121121
});
122122

123+
it('should remove the variant analysis history item', async () => {
124+
await qhm.readQueryHistory();
125+
126+
// Remove the first variant analysis
127+
await qhm.handleRemoveHistoryItem(qhm.treeDataProvider.allHistory[0]);
128+
129+
expect(removeVariantAnalysisStub).calledOnceWithExactly(rawQueryHistory[0].historyItemId);
130+
expect(rehydrateVariantAnalysisStub).to.have.callCount(2);
131+
132+
expect(rehydrateVariantAnalysisStub.getCall(0).args[0]).to.deep.eq(rawQueryHistory[0].variantAnalysis);
133+
expect(rehydrateVariantAnalysisStub.getCall(0).args[1]).to.deep.eq(rawQueryHistory[0].status);
134+
135+
expect(rehydrateVariantAnalysisStub.getCall(1).args[0]).to.deep.eq(rawQueryHistory[1].variantAnalysis);
136+
expect(rehydrateVariantAnalysisStub.getCall(1).args[1]).to.deep.eq(rawQueryHistory[1].status);
137+
138+
expect(openRemoteQueryResultsStub).calledOnceWithExactly(rawQueryHistory[1].historyItemId);
139+
expect(qhm.treeDataProvider.allHistory).to.deep.eq(rawQueryHistory.slice(1));
140+
141+
// Add it back to the history
142+
qhm.addQuery(rawQueryHistory[0]);
143+
expect(removeVariantAnalysisStub).to.have.callCount(1);
144+
expect(rehydrateVariantAnalysisStub).to.have.callCount(2);
145+
expect(qhm.treeDataProvider.allHistory).to.deep.eq([rawQueryHistory[1], rawQueryHistory[0]]);
146+
});
147+
123148
async function copyHistoryState() {
124149
fs.ensureDirSync(STORAGE_DIR);
125150
fs.copySync(

0 commit comments

Comments
 (0)