Skip to content

Commit 0d298fa

Browse files
committed
🎨 added isNotUndefined check for timezone
1 parent 9984755 commit 0d298fa

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

bin/helpers/utils.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ exports.isValidTimezone = (timezone) => {
404404
exports.setTimezone = (bsConfig, args) => {
405405
let timezone = undefined;
406406
if(this.isTimezoneArgPassed()) {
407-
if(!this.isUndefined(args.timezone)) {
407+
if(this.isNotUndefined(args.timezone)) {
408408
if(this.isValidTimezone(args.timezone)){
409409
timezone = args.timezone;
410410
} else {
@@ -413,7 +413,7 @@ exports.setTimezone = (bsConfig, args) => {
413413
process.exit(1);
414414
}
415415
}
416-
} else if (!this.isUndefined(bsConfig.run_settings.timezone)) {
416+
} else if (this.isNotUndefined(bsConfig.run_settings.timezone)) {
417417
if(this.isValidTimezone(bsConfig.run_settings.timezone)){
418418
timezone = bsConfig.run_settings.timezone;
419419
} else {
@@ -591,6 +591,8 @@ exports.fixCommaSeparatedString = (string) => {
591591

592592
exports.isUndefined = value => (value === undefined || value === null);
593593

594+
exports.isNotUndefined = value => !this.isUndefined(value);
595+
594596
exports.isPositiveInteger = (str) => {
595597
if (typeof str !== 'string') {
596598
return false;

test/unit/bin/helpers/utils.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,20 @@ describe('utils', () => {
192192
});
193193
});
194194

195+
describe('isNotUndefined', () => {
196+
it('should return false for a undefined value', () => {
197+
expect(utils.isNotUndefined(undefined)).to.be.equal(false);
198+
expect(utils.isNotUndefined(null)).to.be.equal(false);
199+
});
200+
201+
it('should return true for a defined value', () => {
202+
expect(utils.isNotUndefined(1.234)).to.be.equal(true);
203+
expect(utils.isNotUndefined('1.234')).to.be.equal(true);
204+
expect(utils.isNotUndefined(100)).to.be.equal(true);
205+
expect(utils.isNotUndefined(-1)).to.be.equal(true);
206+
});
207+
});
208+
195209
describe('setParallels', () => {
196210
var sandbox;
197211
beforeEach(() => {

0 commit comments

Comments
 (0)