Comparing version 0.1.0 to 0.2.0
@@ -11,9 +11,10 @@ 'use strict' | ||
function EasyRedis() { | ||
function EasyRedis(filePath) { | ||
if (!(this instanceof EasyRedis)) { | ||
return new EasyRedis(); | ||
return new EasyRedis(filePath); | ||
} | ||
init(filePath); | ||
} | ||
EasyRedis.prototype.init = function (filePath) { | ||
function init (filePath) { | ||
let exists = fs.existsSync(filePath); | ||
@@ -20,0 +21,0 @@ if (exists) { |
{ | ||
"name": "easy-redis", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Just write a config file,you can get one of redis connection with different topic", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
'use strict' | ||
const redis = require('../index')(); | ||
const redis = require('../index')(`${__dirname}/redisConfig.json`); | ||
const should = require('chai').should() | ||
describe('index', function () { | ||
it('init', function () { | ||
redis.init(`${__dirname}/redisConfig.json`).should.equal(true); | ||
}) | ||
it('getConnect', function () { | ||
//need start local redis server | ||
redis.init(`${__dirname}/redisConfig.json`); | ||
redis.getConnect('localhost').should.be.a('object'); | ||
@@ -16,3 +12,2 @@ }) | ||
//need start local redis server | ||
redis.init(`${__dirname}/redisConfig.json`) | ||
redis.getConnect('localhost').setAsync('test', 'oops').then((result) => { | ||
@@ -19,0 +14,0 @@ result.should.equal('OK'); |
4299
102