mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 07:47:49 +00:00
34 lines
864 B
TypeScript
34 lines
864 B
TypeScript
import assert from 'node:assert';
|
|
import lodashStable from 'lodash';
|
|
import runInContext from '../src/runInContext';
|
|
import uniqueId from '../src/uniqueId';
|
|
|
|
describe('runInContext', () => {
|
|
it('should not require a fully populated `context` object', () => {
|
|
const lodash = runInContext({
|
|
setTimeout: function (func) {
|
|
func();
|
|
},
|
|
});
|
|
|
|
let pass = false;
|
|
lodash.delay(() => {
|
|
pass = true;
|
|
}, 32);
|
|
assert.ok(pass);
|
|
});
|
|
|
|
it('should use a zeroed `_.uniqueId` counter', () => {
|
|
lodashStable.times(2, uniqueId);
|
|
|
|
const oldId = Number(uniqueId()),
|
|
lodash = runInContext();
|
|
|
|
assert.ok(uniqueId() > oldId);
|
|
|
|
const id = lodash.uniqueId();
|
|
assert.strictEqual(id, '1');
|
|
assert.ok(id < oldId);
|
|
});
|
|
});
|