@@ -554,6 +554,17 @@ describe("capabilityHelper.js", () => {
554554 } ) ;
555555 } ) ;
556556
557+ describe ( "addCypressZipStartLocation" , ( ) => {
558+ it ( "returns correct zip start location" , ( ) => {
559+ let runSettings = {
560+ home_directory : "/some/path" ,
561+ cypressConfigFilePath : "/some/path/that/is/nested/file.json"
562+ } ;
563+ capabilityHelper . addCypressZipStartLocation ( runSettings ) ;
564+ chai . assert . equal ( runSettings . cypressZipStartLocation , "that/is/nested" ) ;
565+ } ) ;
566+ } ) ;
567+
557568 describe ( "validate" , ( ) => {
558569
559570 describe ( "validate parallels specified in bsconfig and arguments" , ( ) => {
@@ -1053,5 +1064,95 @@ describe("capabilityHelper.js", () => {
10531064 } )
10541065 } ) ;
10551066 } ) ;
1067+
1068+ describe ( "validate home directory" , ( ) => {
1069+ beforeEach ( ( ) => {
1070+ bsConfig = {
1071+ auth : { } ,
1072+ browsers : [
1073+ {
1074+ browser : "chrome" ,
1075+ os : "Windows 10" ,
1076+ versions : [ "78" , "77" ] ,
1077+ } ,
1078+ ] ,
1079+ run_settings : {
1080+ cypress_proj_dir : "random path" ,
1081+ cypressConfigFilePath : "random path" ,
1082+ cypressProjectDir : "random path"
1083+ } ,
1084+ } ;
1085+ } ) ;
1086+
1087+ it ( "does not exist" , ( ) => {
1088+ // sinon.stub(fs, 'existsSync').returns(false);
1089+ bsConfig . run_settings . cypressConfigFilePath = 'false' ;
1090+ bsConfig . run_settings . cypress_config_filename = 'false' ;
1091+ bsConfig . run_settings . home_directory = '/some/random' ;
1092+
1093+ sinon . stub ( fs , 'existsSync' ) . returns ( false ) ;
1094+ fs . existsSync . restore ( ) ;
1095+
1096+ return capabilityHelper
1097+ . validate ( bsConfig , { } )
1098+ . then ( function ( data ) {
1099+ chai . assert . fail ( "Promise error" ) ;
1100+ } )
1101+ . catch ( ( error ) => {
1102+ chai . assert . equal (
1103+ error ,
1104+ Constants . validationMessages . HOME_DIRECTORY_NOT_FOUND
1105+ ) ;
1106+ } ) ;
1107+ } ) ;
1108+
1109+ it ( "is not a directory" , ( ) => {
1110+ // sinon.stub(fs, 'existsSync').returns(false);
1111+ bsConfig . run_settings . cypressConfigFilePath = 'false' ;
1112+ bsConfig . run_settings . cypress_config_filename = 'false' ;
1113+ bsConfig . run_settings . home_directory = '/some/random/file.ext' ;
1114+
1115+ sinon . stub ( fs , 'existsSync' ) . returns ( true ) ;
1116+ sinon . stub ( fs , 'statSync' ) . returns ( { isDirectory : ( ) => false } ) ;
1117+
1118+ return capabilityHelper
1119+ . validate ( bsConfig , { } )
1120+ . then ( function ( data ) {
1121+ chai . assert . fail ( "Promise error" ) ;
1122+ } )
1123+ . catch ( ( error ) => {
1124+ chai . assert . equal (
1125+ error ,
1126+ Constants . validationMessages . HOME_DIRECTORY_NOT_A_DIRECTORY
1127+ ) ;
1128+ fs . existsSync . restore ( ) ;
1129+ fs . statSync . restore ( ) ;
1130+ } ) ;
1131+ } ) ;
1132+
1133+ it ( "does not contain cypressConfigFilePath" , ( ) => {
1134+ // sinon.stub(fs, 'existsSync').returns(false);
1135+ bsConfig . run_settings . cypressConfigFilePath = 'false' ;
1136+ bsConfig . run_settings . cypress_config_filename = 'false' ;
1137+ bsConfig . run_settings . home_directory = '/some/random' ;
1138+
1139+ sinon . stub ( fs , 'existsSync' ) . returns ( true ) ;
1140+ sinon . stub ( fs , 'statSync' ) . returns ( { isDirectory : ( ) => true } ) ;
1141+
1142+ return capabilityHelper
1143+ . validate ( bsConfig , { } )
1144+ . then ( function ( data ) {
1145+ chai . assert . fail ( "Promise error" ) ;
1146+ } )
1147+ . catch ( ( error ) => {
1148+ chai . assert . equal (
1149+ error ,
1150+ Constants . validationMessages . CYPRESS_CONFIG_FILE_NOT_PART_OF_HOME_DIRECTORY
1151+ ) ;
1152+ fs . existsSync . restore ( ) ;
1153+ fs . statSync . restore ( ) ;
1154+ } ) ;
1155+ } ) ;
1156+ } ) ;
10561157 } ) ;
10571158} ) ;
0 commit comments