@@ -482,4 +482,126 @@ describe("utils", () => {
482
482
} ) ;
483
483
484
484
} ) ;
485
+
486
+ describe ( "verifyCypressConfigFileOption" , ( ) => {
487
+ let utilsearchForOptionCypressConfigFileStub , userOption , testOption ;
488
+
489
+ beforeEach ( function ( ) {
490
+ utilsearchForOptionCypressConfigFileStub = sinon
491
+ . stub ( utils , 'searchForOption' )
492
+ . callsFake ( ( ...userOption ) => {
493
+ return ( userOption == testOption ) ;
494
+ } ) ;
495
+ } ) ;
496
+
497
+ afterEach ( function ( ) {
498
+ utilsearchForOptionCypressConfigFileStub . restore ( ) ;
499
+ } ) ;
500
+
501
+ it ( "-ccf user option" , ( ) => {
502
+ testOption = '-ccf' ;
503
+ expect ( utils . verifyCypressConfigFileOption ( ) ) . to . be . true ;
504
+ sinon . assert . calledWithExactly ( utilsearchForOptionCypressConfigFileStub , testOption ) ;
505
+ } ) ;
506
+
507
+ it ( "--ccf user option" , ( ) => {
508
+ testOption = '--ccf' ;
509
+ expect ( utils . verifyCypressConfigFileOption ( ) ) . to . be . true ;
510
+ sinon . assert . calledWithExactly ( utilsearchForOptionCypressConfigFileStub , testOption ) ;
511
+ } ) ;
512
+
513
+ it ( "-cypress-config-file user option" , ( ) => {
514
+ testOption = '-cypress-config-file' ;
515
+ expect ( utils . verifyCypressConfigFileOption ( ) ) . to . be . true ;
516
+ sinon . assert . calledWithExactly ( utilsearchForOptionCypressConfigFileStub , testOption ) ;
517
+ } ) ;
518
+
519
+ it ( "--cypress-config-file user option" , ( ) => {
520
+ testOption = '--cypress-config-file' ;
521
+ expect ( utils . verifyCypressConfigFileOption ( ) ) . to . be . true ;
522
+ sinon . assert . calledWithExactly ( utilsearchForOptionCypressConfigFileStub , testOption ) ;
523
+ } ) ;
524
+
525
+ it ( "-cypressConfigFile user option" , ( ) => {
526
+ testOption = '-cypressConfigFile' ;
527
+ expect ( utils . verifyCypressConfigFileOption ( ) ) . to . be . true ;
528
+ sinon . assert . calledWithExactly ( utilsearchForOptionCypressConfigFileStub , testOption ) ;
529
+ } ) ;
530
+
531
+ it ( "--cypressConfigFile user option" , ( ) => {
532
+ testOption = '--cypressConfigFile' ;
533
+ expect ( utils . verifyCypressConfigFileOption ( ) ) . to . be . true ;
534
+ sinon . assert . calledWithExactly ( utilsearchForOptionCypressConfigFileStub , testOption ) ;
535
+ } ) ;
536
+ } ) ;
537
+
538
+ describe ( "setCypressConfigFilename" , ( ) => {
539
+ let verifyCypressConfigFileOptionStub ,
540
+ ccfBool , args , bsConfig , cypress_config_file ;
541
+
542
+ beforeEach ( function ( ) {
543
+ verifyCypressConfigFileOptionStub = sinon
544
+ . stub ( utils , 'verifyCypressConfigFileOption' )
545
+ . callsFake ( ( ) => ccfBool ) ;
546
+
547
+ args = {
548
+ cypressConfigFile : "args_cypress_config_file"
549
+ } ;
550
+ } ) ;
551
+
552
+ it ( "has user provided ccf flag" , ( ) => {
553
+ ccfBool = true ;
554
+
555
+ bsConfig = {
556
+ run_settings : {
557
+ cypress_config_file : "run_settings_cypress_config_file"
558
+ }
559
+ } ;
560
+
561
+ utils . setCypressConfigFilename ( bsConfig , args ) ;
562
+
563
+ expect ( bsConfig . run_settings . cypress_config_file ) . to . be . eq ( args . cypressConfigFile ) ;
564
+ expect ( bsConfig . run_settings . cypress_config_filename ) . to . be . eq ( path . basename ( args . cypressConfigFile ) ) ;
565
+ expect ( bsConfig . run_settings . userProvidedCypessConfigFile ) . to . be . true ;
566
+ expect ( bsConfig . run_settings . cypressConfigFilePath ) . to . be . eq ( bsConfig . run_settings . cypress_config_file ) ;
567
+ } ) ;
568
+
569
+ it ( "does not have user provided ccf flag, sets the value from cypress_proj_dir" , ( ) => {
570
+ ccfBool = false ;
571
+
572
+ bsConfig = {
573
+ run_settings : {
574
+ cypress_proj_dir : "cypress_proj_dir"
575
+ }
576
+ } ;
577
+
578
+ utils . setCypressConfigFilename ( bsConfig , args ) ;
579
+
580
+ expect ( bsConfig . run_settings . cypress_config_file ) . to . be . eq ( args . cypressConfigFile ) ;
581
+ expect ( bsConfig . run_settings . cypress_config_filename ) . to . be . eq ( path . basename ( args . cypressConfigFile ) ) ;
582
+ expect ( bsConfig . run_settings . userProvidedCypessConfigFile ) . to . be . false ;
583
+ expect ( bsConfig . run_settings . cypressConfigFilePath ) . to . be . eq ( path . join ( bsConfig . run_settings . cypress_proj_dir , 'cypress.json' ) ) ;
584
+ } ) ;
585
+
586
+ it ( "does not have user provided ccf flag, sets from config file" , ( ) => {
587
+ cypress_config_file = "run_settings_cypress_config_file" ;
588
+ ccfBool = false ;
589
+ bsConfig = {
590
+ run_settings : {
591
+ cypress_config_file : cypress_config_file
592
+ }
593
+ } ;
594
+
595
+ utils . setCypressConfigFilename ( bsConfig , args ) ;
596
+
597
+ expect ( bsConfig . run_settings . cypress_config_file ) . to . be . eq ( cypress_config_file ) ;
598
+ expect ( bsConfig . run_settings . cypress_config_filename ) . to . be . eq ( path . basename ( cypress_config_file ) ) ;
599
+ expect ( bsConfig . run_settings . userProvidedCypessConfigFile ) . to . be . true ;
600
+ expect ( bsConfig . run_settings . cypressConfigFilePath ) . to . be . eq ( bsConfig . run_settings . cypress_config_file ) ;
601
+ } ) ;
602
+
603
+ afterEach ( function ( ) {
604
+ verifyCypressConfigFileOptionStub . restore ( ) ;
605
+ } )
606
+ } ) ;
485
607
} ) ;
0 commit comments