boobst
Version:
Simple Node.js Caché driver
87 lines (75 loc) • 2.33 kB
JavaScript
// Generated by CoffeeScript 1.7.1
/*
* @author Andrew D.Laptev <a.d.laptev@gmail.com>
*/
/*global describe, beforeEach, afterEach, it */
(function() {
var BoobstSocket, GLOBAL, assert, boobst;
assert = require('assert');
boobst = require('../boobst');
BoobstSocket = boobst.BoobstSocket;
GLOBAL = '^test1';
describe('order', function() {
var bs;
this.timeout(15000);
bs = new BoobstSocket(require('./test.config'));
beforeEach(function(done) {
return bs.connect(function(err) {
if (err) {
throw err;
}
this.set(GLOBAL, [1, 'city'], 'Moscow');
this.set(GLOBAL, [2, 'city'], 'London');
this.set(GLOBAL, [3, 'city'], 'Paris');
this.set(GLOBAL, [4, 'city'], 'Detroit');
return this.set(GLOBAL, [5, 'city'], 'Ottawa', function() {
return done();
});
});
});
afterEach(function(done) {
return bs.kill(GLOBAL, function() {
return bs.disconnect(function() {
return done();
});
});
});
describe('#order test an empty string', function() {
return it('should return first key', function(done) {
return bs.order(GLOBAL, [''], function(err, data) {
assert.equal(err, null);
assert.equal(data, '1');
return done();
});
});
});
describe('#next method should work as order', function() {
return it('should return first key', function(done) {
return bs.next(GLOBAL, [''], function(err, data) {
assert.equal(err, null);
assert.equal(data, '1');
return done();
});
});
});
describe('#order test a first key', function() {
return it('should return second key', function(done) {
return bs.order(GLOBAL, ['1'], function(err, data) {
assert.equal(err, null);
assert.equal(data, '2');
return done();
});
});
});
return describe('#order test last key', function() {
return it('should return empty string', function(done) {
return bs.order(GLOBAL, ['5'], function(err, data) {
assert.equal(err, null);
assert.equal(data, '');
return done();
});
});
});
});
}).call(this);
//# sourceMappingURL=test.order.map