This repository has been archived by the owner on Dec 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
optimization
- Loading branch information
Mehdi Valikhani
committed
Mar 18, 2015
1 parent
50aadc5
commit afe98a2
Showing
4 changed files
with
69 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
var hasValue = function(val){ | ||
return (typeof val !== 'undefined') && (val !== null); | ||
} | ||
|
||
module.exports = { | ||
hasValue: hasValue | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
var utils = require('../lib/utils'); | ||
var hasValue = utils.hasValue; | ||
|
||
describe("hasValue() util function", function(){ | ||
it('Should return false when value is <null>', function(){ | ||
hasValue(null).should.be.false; | ||
}); | ||
|
||
it('Should return false when value is <undefined>', function(){ | ||
hasValue(undefined).should.be.false; | ||
}); | ||
|
||
it('Should return true when value is a number', function(){ | ||
hasValue(12).should.be.true; | ||
}); | ||
|
||
it('Should return true when value is a string', function(){ | ||
hasValue('a').should.be.true; | ||
}); | ||
|
||
it('Should return true when value is <{}>', function(){ | ||
hasValue({}).should.be.true; | ||
}); | ||
|
||
it('Should return true when value is <"">', function(){ | ||
hasValue('').should.be.true; | ||
}); | ||
}); |