Browse Source

minor test changes, jscs rule update

feature/specify-what-to-cache
Bryan Donovan 10 years ago
parent
commit
01a232411a
  1. 6
      .jscs.json
  2. 4
      lib/multi_caching.js
  3. 27
      test/stores/options.unit.js

6
.jscs.json

@ -2,6 +2,12 @@
"requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch"],
"requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch"],
"requireSpaceBeforeKeywords": [
"else",
"while",
"catch"
],
"requireSpaceBeforeBinaryOperators": ["?", "+", "/", "*", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="],
"requireSpaceAfterBinaryOperators": ["?", "+", "/", "*", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="],
"disallowSpaceAfterBinaryOperators": ["!"],

4
lib/multi_caching.js

@ -34,7 +34,7 @@ var multi_caching = function(caches) {
};
if (typeof options === 'object') {
cache.store.get(key, options, callback);
}else {
} else {
cache.store.get(key, callback);
}
}, cb);
@ -183,7 +183,7 @@ var multi_caching = function(caches) {
async.forEach(caches, function(cache, async_cb) {
if (typeof options === 'object') {
cache.store.del(key, options, async_cb);
}else {
} else {
cache.store.del(key, async_cb);
}
}, cb);

27
test/stores/options.unit.js

@ -85,17 +85,16 @@ var testStore = function(args) {
};
describe("Methods with options", function() {
var testInstance = caching.caching({store: testStore()});
var testCache;
before(function() {
key = support.random.string(20);
value = support.random.string(20);
testCache = caching.multi_caching([testInstance]);
});
describe("get with options", function() {
var testInstance = caching.caching({store: testStore()});
var testCache;
before(function() {
testCache = caching.multi_caching([testInstance]);
});
describe("get with options", function() {
it("lets us pass options by value", function(done) {
var options = {value: value};
testCache.get(key, options, function(err, response) {
@ -116,13 +115,9 @@ describe("Methods with options", function() {
});
});
});
describe("set with options", function() {
var testInstance = caching.caching({store: testStore()});
var testCache;
var ttl = 60;
before(function() {
testCache = caching.multi_caching([testInstance]);
});
it("lets us pass options by value", function(done) {
var options = {ttl: ttl, value: value};
@ -143,13 +138,8 @@ describe("Methods with options", function() {
testCache.set(key, value, options, function() {}, options);
});
});
describe("delete with options", function() {
var testInstance = caching.caching({store: testStore()});
var testCache;
before(function() {
testCache = caching.multi_caching([testInstance]);
});
describe("delete with options", function() {
it("lets us pass options by value", function(done) {
var options = {value: value};
testCache.del(key, options, function() {
@ -169,12 +159,14 @@ describe("Methods with options", function() {
});
});
});
describe("Multiple stores with options", function() {
var testInstance = caching.caching({store: testStore()});
var memInstance = caching.caching({store: "memory"});
var testCache;
var options = {runNormal: true};
var ttl = 1;
before(function() {
key = support.random.string(20);
value = support.random.string(20);
@ -197,6 +189,7 @@ describe("Multiple stores with options", function() {
});
});
});
it("lets us not pass options which only one store uses", function() {
testCache.set(key, value, ttl, function(err) {
check_err(err);

Loading…
Cancel
Save