Add _.once unit tests.

Former-commit-id: cb79b4a5e73ec0cb7bae959693bb14599277ffe0
This commit is contained in:
John-David Dalton
2013-04-09 20:23:58 -07:00
parent a8b6fa413e
commit 9f12552907

View File

@@ -1972,6 +1972,41 @@
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.once');
(function() {
test('should ignore recursive calls', function() {
var count = 0;
var func = _.once(function() {
count++;
func();
});
func();
strictEqual(count, 1);
});
test('should not throw more than once', function() {
var pass = true;
var func = _.once(function() {
throw new Error;
});
raises(function() { func(); }, Error);
try {
func();
} catch(e) {
pass = false;
}
ok(pass);
});
}());
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.parseInt');
(function() {