Enable escape and once tests (#4618)

This commit is contained in:
Luiz Américo
2020-01-08 13:43:03 -08:00
committed by Michał Lipiński
parent cefddab1ca
commit 04ebca6c86
2 changed files with 0 additions and 0 deletions

36
test/once.test.js Normal file
View 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);
});
});