Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
The get method was async some time ago. After this was changed to sync
the tests were not adapted and no assertion was executed.
  • Loading branch information
Mathias Schreck committed Feb 5, 2014
1 parent e31e7a0 commit c44124a
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions test/shared/store/memory_store.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,42 @@ describe('MemoryStore', function() {
});

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

it("should set and get a key + value", function() {
var value;

store.set('cached_value', 42);
store.get('cached_value', function(err, value) {
should.equal(value, 42);
});
value = store.get('cached_value');
should.equal(value, 42);

store.set('cached_value', 'new value');
store.get('cached_value', function(err, value) {
should.equal(value, 'new value');
});
value = store.get('cached_value');
should.equal(value, 'new value');
});

it("should be able to clear a key", function() {
var value;

store.set('somethin', 'some value');
store.clear('somethin');
store.get('somethin', function(err, value) {
should.equal(value, void 0);
});
value = store.get('somethin');

should.equal(value, void 0);
});

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

store.set('will_expire', '1234', 0.01);
store.get('will_expire', function(err, value) {
should.equal(value, '1234');
});
value = store.get('will_expire');
should.equal(value, '1234');

setTimeout(function() {
store.get('will_expire', function(err, value) {
should.equal(value, void 0);
});
value = store.get('will_expire');
should.equal(value, void 0);
done();
}, 11);
});
Expand Down

0 comments on commit c44124a

Please sign in to comment.