@@ -3,6 +3,7 @@ import * as sinon from 'sinon';
33import { expect } from 'chai' ;
44import { window } from 'vscode' ;
55import * as pq from 'proxyquire' ;
6+ import { UserCancellationException } from '../../../commandRunner' ;
67
78const proxyquire = pq . noPreserveCache ( ) ;
89
@@ -13,21 +14,16 @@ describe('repository-selection', function() {
1314 let quickPickSpy : sinon . SinonStub ;
1415 let showInputBoxSpy : sinon . SinonStub ;
1516 let getRemoteRepositoryListsSpy : sinon . SinonStub ;
16- let showAndLogErrorMessageSpy : sinon . SinonStub ;
1717 let mod : any ;
1818 beforeEach ( ( ) => {
1919 sandbox = sinon . createSandbox ( ) ;
2020 quickPickSpy = sandbox . stub ( window , 'showQuickPick' ) ;
2121 showInputBoxSpy = sandbox . stub ( window , 'showInputBox' ) ;
2222 getRemoteRepositoryListsSpy = sandbox . stub ( ) ;
23- showAndLogErrorMessageSpy = sandbox . stub ( ) ;
2423 mod = proxyquire ( '../../../remote-queries/repository-selection' , {
2524 '../config' : {
2625 getRemoteRepositoryLists : getRemoteRepositoryListsSpy
2726 } ,
28- '../helpers' : {
29- showAndLogErrorMessage : showAndLogErrorMessageSpy
30- } ,
3127 } ) ;
3228 } ) ;
3329
@@ -120,11 +116,8 @@ describe('repository-selection', function() {
120116 getRemoteRepositoryListsSpy . returns ( { } ) ; // no pre-defined repo lists
121117 showInputBoxSpy . resolves ( repo ) ;
122118
123- // make the function call
124- await mod . getRepositorySelection ( ) ;
125-
126- // check that we get the right error message
127- expect ( showAndLogErrorMessageSpy . firstCall . args [ 0 ] ) . to . contain ( 'Invalid repository format' ) ;
119+ // function call should throw a UserCancellationException
120+ await expect ( mod . getRepositorySelection ( ) ) . to . be . rejectedWith ( UserCancellationException , 'Invalid repository format' ) ;
128121 } ) ;
129122 } ) ;
130123
0 commit comments