Skip to content

Commit

Permalink
Allowed db config in string form
Browse files Browse the repository at this point in the history
  • Loading branch information
ravenjohn committed Jan 28, 2017
1 parent 4df4b73 commit a4aad99
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 28 deletions.
6 changes: 0 additions & 6 deletions lib/CustomMySQL.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ Object.defineProperty(exports, "__esModule", {
value: true
});

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _Transaction = require('./Transaction');
Expand Down Expand Up @@ -63,10 +61,6 @@ var CustomMySQL = function () {
throw new Error('key should be a string');
}

if ((typeof config === 'undefined' ? 'undefined' : _typeof(config)) !== 'object') {
throw new Error('config should be an object');
}

this._key = key;
this[key] = { config: config };
this[key].is_pool = !!is_pool;
Expand Down
4 changes: 0 additions & 4 deletions src/CustomMySQL.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ export default class CustomMySQL {
throw new Error('key should be a string');
}

if (typeof config !== 'object') {
throw new Error('config should be an object');
}

this._key = key;
this[key] = {config};
this[key].is_pool = !!is_pool;
Expand Down
20 changes: 2 additions & 18 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@

const should = require('chai').should();
const CustomMySQL = require(process.cwd() + '/lib/CustomMySQL').default;
const FREE_DB = {
host: 'localhost',
user: 'root',
password: '',
database: 'test'
};

const FREE_DB = 'mysql://root:@localhost/test';
const FREE_DB2 = {
host: 'localhost',
user: 'root',
Expand Down Expand Up @@ -122,18 +118,6 @@ describe('Overall test', () => {



it ('mysql.add should throw an error if config is not an object', (done) => {
const mysql = new CustomMySQL();

(() => {
mysql.add('key', 1);
}).should.throw(Error, 'config should be an object');

done();
});



it ('mysql.add should create a property for a newly added key-config pair', (done) => {
const mysql = new CustomMySQL();

Expand Down

0 comments on commit a4aad99

Please sign in to comment.