mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 18:17:48 +00:00
Add _.once unit tests.
Former-commit-id: cb79b4a5e73ec0cb7bae959693bb14599277ffe0
This commit is contained in:
35
test/test.js
35
test/test.js
@@ -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');
|
QUnit.module('lodash.parseInt');
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user