Skip to content

Instantly share code, notes, and snippets.

@tlimpanont
Created January 6, 2016 21:03
Show Gist options
  • Save tlimpanont/fb1170ae117b08212e69 to your computer and use it in GitHub Desktop.
Save tlimpanont/fb1170ae117b08212e69 to your computer and use it in GitHub Desktop.
check if object has some value filled
isFilledWithValue = function(object) {
for(var key in object) {
var value = object[key].trim();
if(value || value.length > 0) {
return true;
}
}
return false;
}
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