taggable-via-redis
Version:
Add tagging functionality backed by Redis. This is a rewrite of sintaxi's node-redis-tag.
65 lines (56 loc) • 1.88 kB
JavaScript
// Generated by CoffeeScript 1.6.3
/*
# test for taggabler_via_redis
*/
(function() {
var MODULE_NAME, REDIS_CLIENT, should, taggable;
should = require("should");
taggable = require("../taggabler_via_redis");
REDIS_CLIENT = null;
MODULE_NAME = "people";
describe("basic update tests", function() {
before(function(done) {
var redis;
redis = require("redis");
REDIS_CLIENT = redis.createClient();
REDIS_CLIENT.flushall();
taggable.init(REDIS_CLIENT);
return setTimeout(done, 1800);
});
return describe("taggabler_via_redis", function() {
it("should set tags on person", function(done) {
taggable.set(MODULE_NAME, 21, ["hockey", "basketball", "rugby"], function(err) {
should.not.exist(err);
done();
});
});
it("should set tags on second person", function(done) {
taggable.set(MODULE_NAME, 22, ["hockey"], function(err) {
should.not.exist(err);
done();
});
});
it("should change tags first person", function(done) {
taggable.set(MODULE_NAME, 21, ["cricket", "hockey", "football", "baseball"], function(err) {
should.not.exist(err);
done();
});
});
it("should get tags for person", function(done) {
taggable.get(MODULE_NAME, 21, function(err, tags) {
should.not.exist(err);
tags.sort().should.containDeep(["cricket", "hockey", "football", "baseball"].sort());
done();
});
});
return it("should get hockey as most popular tag", function(done) {
taggable.popular(MODULE_NAME, 5, function(err, tags) {
should.not.exist(err);
tags.length.should.be.below(6);
tags[0].should.containDeep(["hockey", 2]);
done();
});
});
});
});
}).call(this);