Add _.runInContext test for _.uniqueId counter.

This commit is contained in:
John-David Dalton
2014-12-21 23:46:39 -06:00
parent 33e19ce9f6
commit b19033a375

View File

@@ -10703,6 +10703,22 @@
skipTest(); skipTest();
} }
}); });
test('should use a zeroed `_.uniqueId` counter', 3, function() {
if (!isModularize) {
var oldId = (_.uniqueId(), _.uniqueId()),
lodash = _.runInContext();
ok(_.uniqueId() > oldId);
var id = lodash.uniqueId();
strictEqual(id, '1');
ok(id < oldId);
}
else {
skipTest(3);
}
});
}()); }());
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
@@ -12973,9 +12989,8 @@
(function() { (function() {
test('should generate unique ids', 1, function() { test('should generate unique ids', 1, function() {
var actual = []; var actual = _.times(1000, function() {
_.times(1000, function() { return _.uniqueId();
actual.push(_.uniqueId());
}); });
strictEqual(_.uniq(actual).length, actual.length); strictEqual(_.uniq(actual).length, actual.length);