@@ -25,7 +25,7 @@ import {
25
25
ITestsHelper ,
26
26
} from '../../client/testing/common/types' ;
27
27
import { ITestingSettings } from '../../client/testing/configuration/types' ;
28
- import { NONE_SELECTED , UnitTestConfigurationService } from '../../client/testing/configuration' ;
28
+ import { UnitTestConfigurationService } from '../../client/testing/configuration' ;
29
29
30
30
suite ( 'Unit Tests - ConfigurationService' , ( ) => {
31
31
UNIT_TEST_PRODUCTS . forEach ( ( product ) => {
@@ -259,198 +259,6 @@ suite('Unit Tests - ConfigurationService', () => {
259
259
enabled = true ;
260
260
expect ( testConfigService . target . hasConfiguredTests ( workspaceUri ) ) . to . equal ( true ) ;
261
261
} ) ;
262
- test ( 'Prompt to enable a test if a test framework is not enabled' , async ( ) => {
263
- unitTestSettings . setup ( ( u ) => u . pytestEnabled ) . returns ( ( ) => false ) ;
264
- unitTestSettings . setup ( ( u ) => u . unittestEnabled ) . returns ( ( ) => false ) ;
265
-
266
- appShell
267
- . setup ( ( s ) => s . showInformationMessage ( typeMoq . It . isAny ( ) , typeMoq . It . isAny ( ) ) )
268
- . returns ( ( ) => Promise . resolve ( undefined ) )
269
- . verifiable ( typeMoq . Times . once ( ) ) ;
270
-
271
- let exceptionThrown = false ;
272
- try {
273
- await testConfigService . target . displayTestFrameworkError ( workspaceUri ) ;
274
- } catch ( exc ) {
275
- if ( exc !== NONE_SELECTED ) {
276
- throw exc ;
277
- }
278
- exceptionThrown = true ;
279
- }
280
-
281
- expect ( exceptionThrown ) . to . be . equal ( true , 'Exception not thrown' ) ;
282
- appShell . verifyAll ( ) ;
283
- } ) ;
284
- test ( 'Prompt to select a test if a test framework is not enabled' , async ( ) => {
285
- unitTestSettings . setup ( ( u ) => u . pytestEnabled ) . returns ( ( ) => false ) ;
286
- unitTestSettings . setup ( ( u ) => u . unittestEnabled ) . returns ( ( ) => false ) ;
287
-
288
- appShell
289
- . setup ( ( s ) => s . showInformationMessage ( typeMoq . It . isAny ( ) , typeMoq . It . isAny ( ) ) )
290
- . returns ( ( _msg , option ) => Promise . resolve ( option ) )
291
- . verifiable ( typeMoq . Times . once ( ) ) ;
292
-
293
- let exceptionThrown = false ;
294
- let selectTestRunnerInvoked = false ;
295
- try {
296
- testConfigService . callBase = false ;
297
- testConfigService
298
- . setup ( ( t ) => t . selectTestRunner ( typeMoq . It . isAny ( ) ) )
299
- . returns ( ( ) => {
300
- selectTestRunnerInvoked = true ;
301
- return Promise . resolve ( undefined ) ;
302
- } ) ;
303
- await testConfigService . target . displayTestFrameworkError ( workspaceUri ) ;
304
- } catch ( exc ) {
305
- if ( exc !== NONE_SELECTED ) {
306
- throw exc ;
307
- }
308
- exceptionThrown = true ;
309
- }
310
-
311
- expect ( selectTestRunnerInvoked ) . to . be . equal ( true , 'Method not invoked' ) ;
312
- expect ( exceptionThrown ) . to . be . equal ( true , 'Exception not thrown' ) ;
313
- appShell . verifyAll ( ) ;
314
- } ) ;
315
- test ( 'Configure selected test framework and disable others' , async ( ) => {
316
- unitTestSettings . setup ( ( u ) => u . pytestEnabled ) . returns ( ( ) => false ) ;
317
- unitTestSettings . setup ( ( u ) => u . unittestEnabled ) . returns ( ( ) => false ) ;
318
-
319
- const workspaceConfig = typeMoq . Mock . ofType < WorkspaceConfiguration > (
320
- undefined ,
321
- typeMoq . MockBehavior . Strict ,
322
- ) ;
323
- workspaceConfig
324
- . setup ( ( w ) => w . get ( typeMoq . It . isAny ( ) ) )
325
- . returns ( ( ) => true )
326
- . verifiable ( typeMoq . Times . once ( ) ) ;
327
- workspaceService
328
- . setup ( ( w ) => w . getConfiguration ( typeMoq . It . isValue ( 'python' ) , workspaceUri ) )
329
- . returns ( ( ) => workspaceConfig . object )
330
- . verifiable ( typeMoq . Times . once ( ) ) ;
331
-
332
- appShell
333
- . setup ( ( s ) => s . showInformationMessage ( typeMoq . It . isAny ( ) , typeMoq . It . isAny ( ) ) )
334
- . returns ( ( _msg , option ) => Promise . resolve ( option ) )
335
- . verifiable ( typeMoq . Times . once ( ) ) ;
336
-
337
- let selectTestRunnerInvoked = false ;
338
- testConfigService . callBase = false ;
339
- testConfigService
340
- . setup ( ( t ) => t . selectTestRunner ( typeMoq . It . isAny ( ) ) )
341
- . returns ( ( ) => {
342
- selectTestRunnerInvoked = true ;
343
- return Promise . resolve ( product ) ;
344
- } ) ;
345
-
346
- const configMgr = typeMoq . Mock . ofType < ITestConfigurationManager > (
347
- undefined ,
348
- typeMoq . MockBehavior . Strict ,
349
- ) ;
350
- factory
351
- . setup ( ( f ) =>
352
- f . create ( typeMoq . It . isValue ( workspaceUri ) , typeMoq . It . isValue ( product ) , typeMoq . It . isAny ( ) ) ,
353
- )
354
- . returns ( ( ) => configMgr . object )
355
- . verifiable ( typeMoq . Times . once ( ) ) ;
356
-
357
- configMgr
358
- . setup ( ( c ) => c . configure ( typeMoq . It . isValue ( workspaceUri ) ) )
359
- . returns ( ( ) => Promise . resolve ( ) )
360
- . verifiable ( typeMoq . Times . once ( ) ) ;
361
- configMgr
362
- . setup ( ( c ) => c . enable ( ) )
363
- . returns ( ( ) => Promise . resolve ( ) )
364
- . verifiable ( typeMoq . Times . once ( ) ) ;
365
-
366
- await testConfigService . target . displayTestFrameworkError ( workspaceUri ) ;
367
-
368
- expect ( selectTestRunnerInvoked ) . to . be . equal ( true , 'Select Test Runner not invoked' ) ;
369
- appShell . verifyAll ( ) ;
370
- factory . verifyAll ( ) ;
371
- configMgr . verifyAll ( ) ;
372
- workspaceConfig . verifyAll ( ) ;
373
- } ) ;
374
- test ( 'If more than one test framework is enabled, then prompt to select a test framework' , async ( ) => {
375
- unitTestSettings . setup ( ( u ) => u . pytestEnabled ) . returns ( ( ) => true ) ;
376
- unitTestSettings . setup ( ( u ) => u . unittestEnabled ) . returns ( ( ) => true ) ;
377
-
378
- appShell
379
- . setup ( ( s ) => s . showInformationMessage ( typeMoq . It . isAny ( ) , typeMoq . It . isAny ( ) ) )
380
- . returns ( ( ) => Promise . resolve ( undefined ) )
381
- . verifiable ( typeMoq . Times . never ( ) ) ;
382
- appShell
383
- . setup ( ( s ) => s . showQuickPick ( typeMoq . It . isAny ( ) , typeMoq . It . isAny ( ) ) )
384
- . returns ( ( ) => Promise . resolve ( undefined ) )
385
- . verifiable ( typeMoq . Times . once ( ) ) ;
386
-
387
- let exceptionThrown = false ;
388
- try {
389
- await testConfigService . target . displayTestFrameworkError ( workspaceUri ) ;
390
- } catch ( exc ) {
391
- if ( exc !== NONE_SELECTED ) {
392
- throw exc ;
393
- }
394
- exceptionThrown = true ;
395
- }
396
-
397
- expect ( exceptionThrown ) . to . be . equal ( true , 'Exception not thrown' ) ;
398
- appShell . verifyAll ( ) ;
399
- } ) ;
400
- test ( 'If more than one test framework is enabled, then prompt to select a test framework and enable test, but do not configure' , async ( ) => {
401
- unitTestSettings . setup ( ( u ) => u . pytestEnabled ) . returns ( ( ) => true ) ;
402
- unitTestSettings . setup ( ( u ) => u . unittestEnabled ) . returns ( ( ) => true ) ;
403
-
404
- appShell
405
- . setup ( ( s ) => s . showInformationMessage ( typeMoq . It . isAny ( ) , typeMoq . It . isAny ( ) ) )
406
- . returns ( ( _msg , option ) => Promise . resolve ( option ) )
407
- . verifiable ( typeMoq . Times . never ( ) ) ;
408
-
409
- let selectTestRunnerInvoked = false ;
410
- testConfigService . callBase = false ;
411
- testConfigService
412
- . setup ( ( t ) => t . selectTestRunner ( typeMoq . It . isAny ( ) ) )
413
- . returns ( ( ) => {
414
- selectTestRunnerInvoked = true ;
415
- return Promise . resolve ( product ) ;
416
- } ) ;
417
-
418
- let enableTestInvoked = false ;
419
- testConfigService
420
- . setup ( ( t ) => t . enableTest ( typeMoq . It . isValue ( workspaceUri ) , typeMoq . It . isValue ( product ) ) )
421
- . returns ( ( ) => {
422
- enableTestInvoked = true ;
423
- return Promise . resolve ( ) ;
424
- } ) ;
425
-
426
- const configMgr = typeMoq . Mock . ofType < ITestConfigurationManager > (
427
- undefined ,
428
- typeMoq . MockBehavior . Strict ,
429
- ) ;
430
- factory
431
- . setup ( ( f ) =>
432
- f . create ( typeMoq . It . isValue ( workspaceUri ) , typeMoq . It . isValue ( product ) , typeMoq . It . isAny ( ) ) ,
433
- )
434
- . returns ( ( ) => configMgr . object )
435
- . verifiable ( typeMoq . Times . once ( ) ) ;
436
-
437
- configMgr
438
- . setup ( ( c ) => c . configure ( typeMoq . It . isValue ( workspaceUri ) ) )
439
- . returns ( ( ) => Promise . resolve ( ) )
440
- . verifiable ( typeMoq . Times . never ( ) ) ;
441
- configMgr
442
- . setup ( ( c ) => c . enable ( ) )
443
- . returns ( ( ) => Promise . resolve ( ) )
444
- . verifiable ( typeMoq . Times . once ( ) ) ;
445
-
446
- await testConfigService . target . displayTestFrameworkError ( workspaceUri ) ;
447
-
448
- expect ( selectTestRunnerInvoked ) . to . be . equal ( true , 'Select Test Runner not invoked' ) ;
449
- expect ( enableTestInvoked ) . to . be . equal ( false , 'Enable Test is invoked' ) ;
450
- factory . verifyAll ( ) ;
451
- appShell . verifyAll ( ) ;
452
- configMgr . verifyAll ( ) ;
453
- } ) ;
454
262
455
263
test ( 'Prompt to enable and configure selected test framework' , async ( ) => {
456
264
unitTestSettings . setup ( ( u ) => u . pytestEnabled ) . returns ( ( ) => false ) ;
0 commit comments