Skip to content
This repository has been archived by the owner on Dec 15, 2023. It is now read-only.

Commit

Permalink
no longer comma first
Browse files Browse the repository at this point in the history
  • Loading branch information
colestrode committed Jan 4, 2016
1 parent 9fe36f8 commit 2bfd0f2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 29 deletions.
4 changes: 3 additions & 1 deletion .jscsrc
@@ -1,12 +1,14 @@
{
"preset": "google",
"excludeFiles": ["coverage", "node_modules"],
"disallowKeywords": ["with"],
"disallowMultipleLineBreaks": null,
"disallowMultipleVarDecl": null,
"disallowSpaceBeforeComma": true,
"disallowSpacesInsideObjectBrackets": null,
"excludeFiles": ["coverage", "node_modules"],
"maximumLineLength": 120,
"requireCamelCaseOrUpperCaseIdentifiers": null,
"requireCommaBeforeLineBreak": true,
"requireCurlyBraces": null,
"validateIndentation": 4
}
4 changes: 2 additions & 2 deletions index.js
Expand Up @@ -53,8 +53,8 @@ function getStorageObj(hash, client, config) {
return cb(err, res);
}

var parsed
, array = [];
var parsed,
array = [];

for (var i in res) {
parsed = JSON.parse(res[i]);
Expand Down
46 changes: 20 additions & 26 deletions test/index.js
@@ -1,14 +1,12 @@
var should = require('should')
, sinon = require('sinon')
, proxyquire = require('proxyquire').noCallThru();
var should = require('should'), sinon = require('sinon'), proxyquire = require('proxyquire').noCallThru();

require('should-sinon');

describe('Redis', function() {
var Storage
, redisMock
, redisClientMock
, defaultNamespace;
var Storage,
redisMock,
redisClientMock,
defaultNamespace;

beforeEach(function() {
defaultNamespace = 'botkit:store';
Expand Down Expand Up @@ -67,8 +65,7 @@ describe('Redis', function() {

['teams', 'users', 'channels'].forEach(function(method) {
describe(method, function() {
var storageInterface
, hash;
var storageInterface, hash;

beforeEach(function() {
storageInterface = Storage();
Expand All @@ -86,8 +83,8 @@ describe('Redis', function() {
});

it('should get by ID', function() {
var result = '{}'
, cb = sinon.stub();
var result = '{}',
cb = sinon.stub();

redisClientMock.hget.yields(null, result);

Expand All @@ -111,8 +108,7 @@ describe('Redis', function() {
});

it('should call the callback with an error if redis fails', function() {
var cb = sinon.stub()
, err = new Error('OOPS!');
var cb = sinon.stub(), err = new Error('OOPS!');

redisClientMock.hget.yields(err);

Expand All @@ -135,8 +131,8 @@ describe('Redis', function() {
});

it('should throw an error if ID is not provided', function() {
var obj = {}
, cb = sinon.stub();
var obj = {},
cb = sinon.stub();

storageInterface[method].save(obj, cb);

Expand All @@ -145,8 +141,7 @@ describe('Redis', function() {
});

it('should save to redis', function() {
var obj = {id: 'heisenberg'}
, cb = sinon.stub();
var obj = {id: 'heisenberg'}, cb = sinon.stub();

storageInterface[method].save(obj, cb);

Expand All @@ -165,16 +160,15 @@ describe('Redis', function() {

beforeEach(function() {
sinon.spy(JSON, 'parse');
//sinon.spy(JSON, 'parse');
});

afterEach(function() {
JSON.parse.restore();
});

it('should call callback with error if redis fails', function() {
var cb = sinon.stub()
, err = new Error('OOPS!');
var cb = sinon.stub(),
err = new Error('OOPS!');

redisClientMock.hgetall.yields(err);

Expand All @@ -196,8 +190,8 @@ describe('Redis', function() {
});

it('should return an array by default', function() {
var cb = sinon.stub()
, result = ['{"walterwhite":"heisenberg"}', '{"jessepinkman":"capncook"}'];
var cb = sinon.stub(),
result = ['{"walterwhite":"heisenberg"}', '{"jessepinkman":"capncook"}'];

redisClientMock.hgetall.yields(null, result);

Expand All @@ -209,8 +203,8 @@ describe('Redis', function() {
});

it('should return an object if specified in options', function() {
var cb = sinon.stub()
, result = {key1: '{"walterwhite":"heisenberg"}', key2: '{"jessepinkman":"capncook"}'};
var cb = sinon.stub(),
result = {key1: '{"walterwhite":"heisenberg"}', key2: '{"jessepinkman":"capncook"}'};

redisClientMock.hgetall.yields(null, result);

Expand All @@ -225,8 +219,8 @@ describe('Redis', function() {
});

it('should return an array if something other than object is specified in options', function() {
var cb = sinon.stub()
, result = ['{"walterwhite":"heisenberg"}', '{"jessepinkman":"capncook"}'];
var cb = sinon.stub(),
result = ['{"walterwhite":"heisenberg"}', '{"jessepinkman":"capncook"}'];

redisClientMock.hgetall.yields(null, result);

Expand Down

0 comments on commit 2bfd0f2

Please sign in to comment.