diff --git a/test/spec/CacheWithDefaultsSpec.js b/test/spec/CacheWithDefaultsSpec.js index 242274f..ec787e9 100644 --- a/test/spec/CacheWithDefaultsSpec.js +++ b/test/spec/CacheWithDefaultsSpec.js @@ -16,6 +16,10 @@ describe('a cache with defaults', function () { }); it('should reset the cache to defaults when calling reset', function () { - cacheWithDefaults.get('#elcacheo') + expect(cacheWithDefaults.cache['#elcacheo']).toBeDefined(); + cacheWithDefaults.unset('#elcacheo'); + expect(cacheWithDefaults.cache['#elcacheo']).toBeUndefined(); + cacheWithDefaults.reset(); + expect(cacheWithDefaults.cache['#elcacheo']).toBeDefined(); }); }); \ No newline at end of file diff --git a/test/spec/CacheWithInitializationSpec.js b/test/spec/CacheWithInitializationSpec.js new file mode 100644 index 0000000..4d8098c --- /dev/null +++ b/test/spec/CacheWithInitializationSpec.js @@ -0,0 +1,34 @@ +var CacheWithInitialization = ElCacheo.Cache.extend({ + initialize: function (cache, options) { + this.passedInCache = cache; + this.passedInOptions = options; + } +}); + +var initialCache = { + 'body': $('body') +}; + +var initialOptions = { + someOption: "someOption's value" +}; + +var cacheWithInitialization = new CacheWithInitialization(initialCache, initialOptions); + +describe('a cache with initialization', function () { + it('should have a passedInCache property', function () { + expect(cacheWithInitialization.passedInCache).toBeDefined(); + }); + + it('should have a passedInCache property equal to initialCache', function () { + expect(cacheWithInitialization.passedInCache).toEqual(initialCache); + }); + + it('should have a passedInOptions property', function () { + expect(cacheWithInitialization.passedInOptions).toBeDefined(); + }); + + it('should have a passedInOptions property equal to initialOptions', function () { + expect(cacheWithInitialization.passedInOptions).toEqual(initialOptions); + }); +}); \ No newline at end of file diff --git a/test/spec/SpecHelper.js b/test/spec/SpecHelper.js index 6ffc9d7..4e3418b 100644 --- a/test/spec/SpecHelper.js +++ b/test/spec/SpecHelper.js @@ -1,15 +1,5 @@ beforeEach(function() { this.addMatchers({ - toBeCached: function(selector) { - var cache = this.actual; - return cache.cache[selector] != null; - }, - - toNotBeCached: function(selector) { - var cache = this.actual; - return cache.cache[selector] == null; - }, - toBeAFunction: function() { return _.isFunction(this.actual); }, diff --git a/test/specrunner.html b/test/specrunner.html index cda3118..a86082f 100644 --- a/test/specrunner.html +++ b/test/specrunner.html @@ -15,6 +15,7 @@ +