mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 17:07:49 +00:00
Enable escape and once tests (#4618)
This commit is contained in:
committed by
Michał Lipiński
parent
cefddab1ca
commit
04ebca6c86
36
test/once.test.js
Normal file
36
test/once.test.js
Normal file
@@ -0,0 +1,36 @@
|
||||
import assert from 'assert';
|
||||
import { _ } from './utils.js';
|
||||
|
||||
describe('once', function() {
|
||||
it('should invoke `func` once', function() {
|
||||
var count = 0,
|
||||
once = _.once(function() { return ++count; });
|
||||
|
||||
once();
|
||||
assert.strictEqual(once(), 1);
|
||||
assert.strictEqual(count, 1);
|
||||
});
|
||||
|
||||
it('should ignore recursive calls', function() {
|
||||
var count = 0;
|
||||
|
||||
var once = _.once(function() {
|
||||
once();
|
||||
return ++count;
|
||||
});
|
||||
|
||||
assert.strictEqual(once(), 1);
|
||||
assert.strictEqual(count, 1);
|
||||
});
|
||||
|
||||
it('should not throw more than once', function() {
|
||||
var once = _.once(function() {
|
||||
throw new Error;
|
||||
});
|
||||
|
||||
assert.throws(once);
|
||||
|
||||
once();
|
||||
assert.ok(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user