Skip to content

Commit

Permalink
use closure instead of this context
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathias Schreck committed Feb 5, 2014
1 parent 24e1149 commit cb3558f
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions test/shared/store/memory_store.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,44 @@ var MemoryStore = require('../../../shared/store/memory_store'),
should = require('chai').should();

describe('MemoryStore', function() {
var store;

beforeEach(function() {
this.store = new MemoryStore;
store = new MemoryStore;
});

it("should undefined for missing keys", function() {
this.store.get('foobar', function(err, value) {
store.get('foobar', function(err, value) {
should.equal(value, void 0);
});
});

it("should set and get a key + value", function() {
this.store.set('cached_value', 42);
this.store.get('cached_value', function(err, value) {
store.set('cached_value', 42);
store.get('cached_value', function(err, value) {
should.equal(value, 42);
});
this.store.set('cached_value', 'new value');
this.store.get('cached_value', function(err, value) {
store.set('cached_value', 'new value');
store.get('cached_value', function(err, value) {
should.equal(value, 'new value');
});
});

it("should be able to clear a key", function() {
this.store.set('somethin', 'some value');
this.store.clear('somethin');
this.store.get('somethin', function(err, value) {
store.set('somethin', 'some value');
store.clear('somethin');
store.get('somethin', function(err, value) {
should.equal(value, void 0);
});
});

it("should be able to expire a key", function(done) {
var _this = this;

this.store.set('will_expire', '1234', 0.01);
this.store.get('will_expire', function(err, value) {
store.set('will_expire', '1234', 0.01);
store.get('will_expire', function(err, value) {
should.equal(value, '1234');
});
setTimeout(function() {
_this.store.get('will_expire', function(err, value) {
store.get('will_expire', function(err, value) {
should.equal(value, void 0);
});
done();
Expand Down

0 comments on commit cb3558f

Please sign in to comment.