Skip to content

Commit

Permalink
General improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
valtlfelipe committed Mar 4, 2018
1 parent 2dd84cf commit 19e0d16
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 8 deletions.
4 changes: 3 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 8
},
"rules": {
"quotes": [2, "single", { "allowTemplateLiterals": true }]
},
"env": {
"node": true
"node": true,
"es6": true
}
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ hapi.js plugin for the Sequelize ORM
### What's the difference between hapi-sequelize and hapi-sequelizejs?

The reason of creating this fork is the inactivity of the original [hapi-sequelize](https://github.com/danecando/hapi-sequelize) plugin.
See the [Migration guide](https://github.com/valtlfelipe/hapi-sequelizejs/wiki/Migration-guide)
See the [Migration guide](https://github.com/valtlfelipe/hapi-sequelizejs/wiki/Migration-guide).

### Compatibility

Compatible with hapi.js version `16.x` and sequelize `4.x`.
Compatible with hapi.js version `17.x` and sequelize `4.x`.

### Installation

Expand Down
2 changes: 1 addition & 1 deletion lib/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async function getFiles(paths, ignored) {
}

async function load(files, fn) {
if (!files) return resolve([]);
if (!files) return Promise.resolve([]);
if (!Array.isArray(files)) files = [files];

return files.reduce((acc, file) => {
Expand Down
29 changes: 25 additions & 4 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ const Sequelize = require('sequelize');

const DB = require('../lib/DB');

// Module globals
const internals = {};

// Test shortcutse
const lab = (exports.lab = Lab.script());
const { suite, test } = lab;
Expand Down Expand Up @@ -231,6 +228,30 @@ suite('hapi-sequelizejs', () => {
},
]);
});

test('should call onConnect with a promise', () => {
const server = new Hapi.Server();

return server.register([
{
plugin: require('../lib/'),
options: [
{
name: 'test',
sequelize: new Sequelize('test', null, null, {
logging: false,
dialect: 'sqlite',
storage: Path.join(__dirname, 'db.sqlite'),
}),
onConnect: instance => {
expect(instance).to.be.instanceof(DB);
return Promise.resolve();
},
},
],
},
]);
});

test('should throw error on getting invalid named DB instance', async () => {
const server = new Hapi.Server();
Expand All @@ -257,7 +278,7 @@ suite('hapi-sequelizejs', () => {
{
method: 'GET',
path: '/',
handler(request, reply) {
handler(request) {
try {
request.getDb('inexistent');
} catch (err) {
Expand Down

0 comments on commit 19e0d16

Please sign in to comment.