Improve LRUCache containsKey test, thanks @tschaub

This commit is contained in:
Tom Payne
2013-02-07 12:20:53 +01:00
parent f7ba03f4dd
commit 218bf2c78b
2 changed files with 30 additions and 3 deletions

View File

@@ -99,11 +99,38 @@ describe('ol.structs.LRUCache', function() {
});
});
describe('setting a disallowed key', function() {
it('raises an exception', function() {
describe('disallowed keys', function() {
it('setting raises an exception', function() {
expect(function() {
lruCache.set('constructor', 0);
}).toThrow();
expect(function() {
lruCache.set('hasOwnProperty', 0);
}).toThrow();
expect(function() {
lruCache.set('isPrototypeOf', 0);
}).toThrow();
expect(function() {
lruCache.set('propertyIsEnumerable', 0);
}).toThrow();
expect(function() {
lruCache.set('toLocaleString', 0);
}).toThrow();
expect(function() {
lruCache.set('toString', 0);
}).toThrow();
expect(function() {
lruCache.set('valueOf', 0);
}).toThrow();
});
it('getting returns false', function() {
expect(lruCache.containsKey('constructor')).toBeFalsy();
expect(lruCache.containsKey('hasOwnProperty')).toBeFalsy();
expect(lruCache.containsKey('isPrototypeOf')).toBeFalsy();
expect(lruCache.containsKey('propertyIsEnumerable')).toBeFalsy();
expect(lruCache.containsKey('toLocaleString')).toBeFalsy();
expect(lruCache.containsKey('toString')).toBeFalsy();
expect(lruCache.containsKey('valueOf')).toBeFalsy();
});
});