Add tests for handleCopyRepoList and handleExportResults

This commit is contained in:
Koen Vlaswinkel
2022-11-15 14:13:32 +01:00
parent e9681bc546
commit 5ed4981673

View File

@@ -495,6 +495,96 @@ describe('query-history', () => {
});
});
describe('handleCopyRepoList', () => {
it('should not call a command for a local query', async () => {
queryHistoryManager = await createMockQueryHistory(localQueryHistory);
const item = localQueryHistory[4];
await queryHistoryManager.handleCopyRepoList(item, [item]);
expect(executeCommandSpy).to.not.have.been.called;
});
it('should copy repo list for a single remote query', async () => {
queryHistoryManager = await createMockQueryHistory(allHistory);
const item = remoteQueryHistory[1];
await queryHistoryManager.handleCopyRepoList(item, [item]);
expect(executeCommandSpy).to.have.been.calledWith('codeQL.copyRepoList', item.queryId);
});
it('should not copy repo list for multiple remote queries', async () => {
queryHistoryManager = await createMockQueryHistory(allHistory);
const item1 = remoteQueryHistory[1];
const item2 = remoteQueryHistory[3];
await queryHistoryManager.handleCopyRepoList(item1, [item1, item2]);
expect(executeCommandSpy).not.to.have.been.called;
});
it('should copy repo list for a single variant analysis', async () => {
queryHistoryManager = await createMockQueryHistory(allHistory);
const item = variantAnalysisHistory[1];
await queryHistoryManager.handleCopyRepoList(item, [item]);
expect(executeCommandSpy).to.have.been.calledWith('codeQL.copyVariantAnalysisRepoList', item.variantAnalysis.id);
});
it('should not copy repo list for multiple variant analyses', async () => {
queryHistoryManager = await createMockQueryHistory(allHistory);
const item1 = variantAnalysisHistory[1];
const item2 = variantAnalysisHistory[3];
await queryHistoryManager.handleCopyRepoList(item1, [item1, item2]);
expect(executeCommandSpy).not.to.have.been.called;
});
});
describe('handleExportResults', () => {
it('should not call a command for a local query', async () => {
queryHistoryManager = await createMockQueryHistory(localQueryHistory);
const item = localQueryHistory[4];
await queryHistoryManager.handleExportResults(item, [item]);
expect(executeCommandSpy).to.not.have.been.called;
});
it('should export results for a single remote query', async () => {
queryHistoryManager = await createMockQueryHistory(allHistory);
const item = remoteQueryHistory[1];
await queryHistoryManager.handleExportResults(item, [item]);
expect(executeCommandSpy).to.have.been.calledWith('codeQL.exportRemoteQueryResults', item.queryId);
});
it('should not export results for multiple remote queries', async () => {
queryHistoryManager = await createMockQueryHistory(allHistory);
const item1 = remoteQueryHistory[1];
const item2 = remoteQueryHistory[3];
await queryHistoryManager.handleExportResults(item1, [item1, item2]);
expect(executeCommandSpy).not.to.have.been.called;
});
it('should export results for a single variant analysis', async () => {
queryHistoryManager = await createMockQueryHistory(allHistory);
const item = variantAnalysisHistory[1];
await queryHistoryManager.handleExportResults(item, [item]);
expect(executeCommandSpy).to.have.been.calledWith('codeQL.exportVariantAnalysisResults', item.variantAnalysis.id);
});
it('should not export results for multiple variant analyses', async () => {
queryHistoryManager = await createMockQueryHistory(allHistory);
const item1 = variantAnalysisHistory[1];
const item2 = variantAnalysisHistory[3];
await queryHistoryManager.handleExportResults(item1, [item1, item2]);
expect(executeCommandSpy).not.to.have.been.called;
});
});
describe('determineSelection', () => {
const singleItem = 'a';
const multipleItems = ['b', 'c', 'd'];