mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-02 08:07:50 +00:00
Add clear method to MapCache.
This commit is contained in:
committed by
John-David Dalton
parent
71fb66dc37
commit
380435d020
22
test/test.js
22
test/test.js
@@ -12485,6 +12485,28 @@
|
||||
|
||||
_.memoize.Cache = oldCache;
|
||||
});
|
||||
|
||||
QUnit.test('should allow clearing cache', function(assert) {
|
||||
assert.expect(5);
|
||||
|
||||
var memoized = _.memoize(_.identity);
|
||||
|
||||
assert.strictEqual(memoized.cache.has('a'), false);
|
||||
|
||||
memoized('a');
|
||||
|
||||
assert.strictEqual(memoized.cache.has('a'), true);
|
||||
|
||||
memoized.cache.clear();
|
||||
|
||||
assert.strictEqual(memoized.cache.has('a'), false);
|
||||
|
||||
memoized('a');
|
||||
memoized('b');
|
||||
|
||||
assert.strictEqual(memoized.cache.has('a'), true);
|
||||
assert.strictEqual(memoized.cache.has('b'), true);
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user