Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6d0d862
commit 48bdd08
Showing
7 changed files
with
348 additions
and
325 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,61 @@ | ||
describe("CacheContent", function() { | ||
/* | ||
var cache1, | ||
cache2, | ||
storage = { | ||
_caches: {}, | ||
setItem: function(key, content){ | ||
this._caches[key] = content; | ||
}, | ||
getItem: function(key){ | ||
if (!this._caches[key]){ | ||
return false; | ||
} | ||
return this._caches[key]; | ||
}, | ||
removeItem: function(key){ | ||
delete this._caches[key]; | ||
} | ||
}, | ||
cacheKey = cache1.getKey(), | ||
cacheLimit = 1 * 60 * 60 * 1000 + new Date().getTime(), | ||
cacheContent = { | ||
foo: 'foo', | ||
bar: 'bar' | ||
}; | ||
*/ | ||
beforeEach(function() { | ||
/* cache1 = new CacheContent({ | ||
storage: storage, | ||
key: 'name=foo&age=28', | ||
limit: limit, | ||
content: cacheContent | ||
}); | ||
|
||
cache2 = new CacheContent({ | ||
storage: storage, | ||
key: 'name=foo&age=28', | ||
limit: new Date().getTime(), | ||
content: cacheContent | ||
it("storage is equal", function(){ | ||
var cache = new CacheManager.CacheContent({ | ||
storage: CacheManager.HashStorage | ||
}); | ||
storage.setItem('name=foo&age=28', cache1); | ||
*/ | ||
expect(cache.getStorage()).toEqual(CacheManager.HashStorage); | ||
}); | ||
|
||
// | ||
it("storage is equal", function() { | ||
// expect(cache1.getStorage()).toEqual(storage); | ||
expect(true).toEqual(true); | ||
}); | ||
/* | ||
it ("key is equal", function() { | ||
expect(cache1.getKey()).toEqual('name=foo&age=28'); | ||
it("key is equal", function() { | ||
var cache = new CacheManager.CacheContent({ | ||
key: 'foo' | ||
}); | ||
expect(cache.getKey()).toEqual('foo'); | ||
}); | ||
|
||
it ("limit is equal", function() { | ||
expect(cache1.getLimit()).toEqual(cacheLimit); | ||
it("limit is equal", function() { | ||
var cache = new CacheManager.CacheContent({ | ||
limit: 1000 | ||
}); | ||
expect(cache.getLimit()).toEqual(1000); | ||
}); | ||
|
||
it ("content is equal", function() { | ||
expect(cache1.getContent()).toEqual(content); | ||
it("content is equal", function() { | ||
var content = { name: 'foo' } | ||
var cache = new CacheManager.CacheContent({ | ||
content: content | ||
}); | ||
expect(cache.getContent()).toEqual(content); | ||
}); | ||
|
||
it ("limit", function() { | ||
expect(cache1.isLimit()).toEqual(false); | ||
it("limit is valid", function() { | ||
var cache = null; | ||
|
||
cache = new CacheManager.CacheContent({ | ||
limit: new Date().getTime() | ||
}); | ||
expect(cache.isLimit()).toEqual(true); | ||
|
||
cache = new CacheManager.CacheContent({ | ||
limit: new Date().getTime() + (1 * 60 * 60 * 1000) | ||
}); | ||
expect(cache.isLimit()).toEqual(false); | ||
}); | ||
|
||
setTimeout(function(){ | ||
it("destroy", function() { | ||
|
||
it ("limit is over", function() { | ||
expect(cache2.isLimit()).toEqual(true); | ||
var cache = null; | ||
|
||
cache = new CacheManager.CacheContent({ | ||
key: 'foo', | ||
storage: CacheManager.HashStorage, | ||
limit: new Date().getTime() + (1 * 60 * 60 * 1000) | ||
}); | ||
}, 100); | ||
|
||
it ("destroy", function() { | ||
cacheKey = cache1.getKey(); | ||
cache1.destroy(); | ||
expect(storage.getItem(cacheKey)).toEqual(false); | ||
cache.destroy(); | ||
|
||
expect(CacheManager.HashStorage.getItem('foo')).toEqual(null); | ||
}); | ||
*/ | ||
|
||
}); |
Oops, something went wrong.