Skip to content

Commit

Permalink
Adding the test for undefined check
Browse files Browse the repository at this point in the history
  • Loading branch information
Karthikeyan Govindaraj committed Apr 5, 2018
1 parent ceff72a commit 9bd3f6c
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 19 deletions.
59 changes: 44 additions & 15 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ function nestedEmptyCheck(obj) {
return true;
}

else if(obj === undefined) {
return true;
}

else if(typeof obj === "boolean"){
return false;
}
Expand Down Expand Up @@ -62,6 +58,9 @@ function nestedEmptyCheck(obj) {
* @returns {boolean}
*/
function isEmptyObj(object) {
if(object === undefined)
return true;

var objToSend = JSON.parse(JSON.stringify(object));
var result = nestedEmptyCheck(objToSend);
if(JSON.stringify(result).indexOf('false') > -1)
Expand Down
2 changes: 2 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var k ={ system: [ { a: [1,2], c: [5,6], }, 2]}
var l = {source: {}, type: "", pool: {}, acquireConnectionTimeout: '', system: [ { a: [], c: [] }, ] }
var m = {a:" "}
var n = {a:true}
var o = {a: undefined};


test('isEmptyObj Testing', function(assert) {
Expand All @@ -34,6 +35,7 @@ test('isEmptyObj Testing', function(assert) {
assert.equal(isEmptyObj(l), true);
assert.equal(isEmptyObj(m), true);
assert.equal(isEmptyObj(n), false);
assert.equal(isEmptyObj(o), true);
assert.end()
})

0 comments on commit 9bd3f6c

Please sign in to comment.