Permalink
Browse files

added more unit tests

  • Loading branch information...
1 parent 227f5f0 commit 3dd79e123886dd4651430e02abd15e318c2d67b7 @craigmaslowski committed Nov 23, 2011
Showing with 40 additions and 11 deletions.
  1. +5 −1 test/spec/CacheWithDefaultsSpec.js
  2. +34 −0 test/spec/CacheWithInitializationSpec.js
  3. +0 −10 test/spec/SpecHelper.js
  4. +1 −0 test/specrunner.html
@@ -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();
});
});
@@ -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);
+ });
+});
@@ -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);
},
@@ -15,6 +15,7 @@
<script src="spec/SpecHelper.js"></script>
<script src="spec/ElCacheoSpec.js"></script>
<script src="spec/CacheWithDefaultsSpec.js"></script>
+ <script src="spec/CacheWithInitializationSpec.js"></script>
<script>
(function() {

0 comments on commit 3dd79e1

Please sign in to comment.