Created
January 6, 2016 21:03
-
-
Save tlimpanont/fb1170ae117b08212e69 to your computer and use it in GitHub Desktop.
check if object has some value filled
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| isFilledWithValue = function(object) { | |
| for(var key in object) { | |
| var value = object[key].trim(); | |
| if(value || value.length > 0) { | |
| return true; | |
| } | |
| } | |
| return false; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe("check object method", function() { | |
| it("should return has value", function() { | |
| var data = { a: '', b: 'some value' }; | |
| expect(isFilledWithValue(data)).toBe(true); | |
| }); | |
| it("should return has no value", function() { | |
| var data = {a: '', b: ''}; | |
| expect(isFilledWithValue(data)).toBe(false); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment