nodeclub/test/common/cache.test.js
2015-04-04 18:30:45 +08:00

25 lines
633 B
JavaScript

var cache = require('../../common/cache');
var should = require('should');
describe('test/common/cache.test.js', function () {
it('should set && get', function (done) {
cache.set('alsotang', {age: 23}, function () {
cache.get('alsotang', function (err, data) {
data.should.eql({age: 23});
done();
});
});
});
it('should expire', function (done) {
cache.set('alsotang', {age: 23}, 1, function () {
setTimeout(function () {
cache.get('alsotang', function (err, data) {
should.not.exist(data);
done();
});
}, 1.5 * 1000);
});
});
});