Skip to content

Commit 501c9d1

Browse files
committed
added more spec
1 parent 544c10c commit 501c9d1

File tree

2 files changed

+136
-0
lines changed

2 files changed

+136
-0
lines changed

test/unit/bin/helpers/capabilityHelper.js

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,6 +1229,98 @@ describe("capabilityHelper.js", () => {
12291229
});
12301230
});
12311231

1232+
describe("validate interactive caps debugging", () => {
1233+
let loggerWarningSpy;
1234+
beforeEach(() => {
1235+
loggerWarningSpy = sinon.stub(logger, 'warn').returns('You have passed an invalid value to the interactive_debugging capability. Proceeding with the default value (True).');
1236+
});
1237+
1238+
afterEach(function() {
1239+
loggerWarningSpy.restore();
1240+
});
1241+
it("show the warning if interactive_debugging passed is a non boolean value", () => {
1242+
let bsConfig = {
1243+
auth: {},
1244+
browsers: [
1245+
{
1246+
browser: "chrome",
1247+
os: "Windows 10",
1248+
versions: ["78", "77"],
1249+
},
1250+
],
1251+
run_settings: {
1252+
cypress_proj_dir: "random path",
1253+
cypressConfigFilePath: "random path",
1254+
cypressProjectDir: "random path",
1255+
cypress_config_filename: "false",
1256+
interactive_debugging: "abc"
1257+
},
1258+
connection_settings: {}
1259+
}
1260+
// sinon.assert.calledWith(loggerWarningSpy, 'You have passed an invalid value to the interactive_debugging capability. Proceeding with the default value (True).');
1261+
return capabilityHelper
1262+
.validate(bsConfig, {})
1263+
.then(function (data) {
1264+
sinon.assert.calledWith(loggerWarningSpy, 'You have passed an invalid value to the interactive_debugging capability. Proceeding with the default value (True).');
1265+
});
1266+
});
1267+
1268+
it("show the warning if interactiveDebugging passed is a non boolean value", () => {
1269+
let bsConfig = {
1270+
auth: {},
1271+
browsers: [
1272+
{
1273+
browser: "chrome",
1274+
os: "Windows 10",
1275+
versions: ["78", "77"],
1276+
},
1277+
],
1278+
run_settings: {
1279+
cypress_proj_dir: "random path",
1280+
cypressConfigFilePath: "random path",
1281+
cypressProjectDir: "random path",
1282+
cypress_config_filename: "false",
1283+
interactiveDebugging: "abc"
1284+
},
1285+
connection_settings: {}
1286+
}
1287+
// sinon.assert.calledWith(loggerWarningSpy, 'You have passed an invalid value to the interactive_debugging capability. Proceeding with the default value (True).');
1288+
return capabilityHelper
1289+
.validate(bsConfig, {})
1290+
.then(function (data) {
1291+
sinon.assert.calledWith(loggerWarningSpy, 'You have passed an invalid value to the interactive_debugging capability. Proceeding with the default value (True).');
1292+
});
1293+
});
1294+
1295+
it("show the warning if both the interactive caps are non boolean", () => {
1296+
let bsConfig = {
1297+
auth: {},
1298+
browsers: [
1299+
{
1300+
browser: "chrome",
1301+
os: "Windows 10",
1302+
versions: ["78", "77"],
1303+
},
1304+
],
1305+
run_settings: {
1306+
cypress_proj_dir: "random path",
1307+
cypressConfigFilePath: "random path",
1308+
cypressProjectDir: "random path",
1309+
cypress_config_filename: "false",
1310+
interactiveDebugging: "def",
1311+
interactive_debugging: "abc"
1312+
},
1313+
connection_settings: {}
1314+
}
1315+
// sinon.assert.calledWith(loggerWarningSpy, 'You have passed an invalid value to the interactive_debugging capability. Proceeding with the default value (True).');
1316+
return capabilityHelper
1317+
.validate(bsConfig, {})
1318+
.then(function (data) {
1319+
sinon.assert.calledWith(loggerWarningSpy, 'You have passed an invalid value to the interactive_debugging capability. Proceeding with the default value (True).');
1320+
});
1321+
});
1322+
});
1323+
12321324
describe("validate home directory", () => {
12331325
beforeEach(() => {
12341326
bsConfig = {

test/unit/bin/helpers/utils.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3938,6 +3938,50 @@ describe('utils', () => {
39383938
});
39393939
});
39403940

3941+
describe('#isNonBooleanValue' , () => {
3942+
it('return true if value passed in empty string', () => {
3943+
expect(utils.isNonBooleanValue('')).to.be.eql(true);
3944+
});
3945+
3946+
it('return true if value passed is abc(non boolean)', () => {
3947+
expect(utils.isNonBooleanValue("abc")).to.be.eql(true);
3948+
});
3949+
3950+
it('return false if value passed is false(boolean)', () => {
3951+
expect(utils.isNonBooleanValue("false")).to.be.eql(false);
3952+
});
3953+
3954+
it('return false if value passed is true(boolean)', () => {
3955+
expect(utils.isNonBooleanValue(true)).to.be.eql(false);
3956+
});
3957+
});
3958+
3959+
describe('#isConflictingBooleanValues' , () => {
3960+
it('return false if value passed is true and true', () => {
3961+
expect(utils.isConflictingBooleanValues(true, true)).to.be.eql(false);
3962+
});
3963+
3964+
it('return false if value passed is false and "false"', () => {
3965+
expect(utils.isConflictingBooleanValues(false, "false")).to.be.eql(false);
3966+
});
3967+
3968+
it('return true if value passed is "true" and "false"', () => {
3969+
expect(utils.isConflictingBooleanValues("true", "false")).to.be.eql(true);
3970+
});
3971+
3972+
it('return true if value passed is true and "false"', () => {
3973+
expect(utils.isConflictingBooleanValues(true, "false")).to.be.eql(true);
3974+
});
3975+
3976+
it('return false if value passed is false and "true"', () => {
3977+
expect(utils.isConflictingBooleanValues(false, "true")).to.be.eql(true);
3978+
});
3979+
3980+
it('return false if value passed is false and "false"', () => {
3981+
expect(utils.isConflictingBooleanValues(false, "false")).to.be.eql(false);
3982+
});
3983+
});
3984+
39413985
describe('#setInteractiveCapability' , () => {
39423986
it('should set true if interactive caps is not passed', () => {
39433987
let bsConfig = {

0 commit comments

Comments
 (0)