#235 getMana back unit test plus helpers setup

This commit is contained in:
Carlos Jimenez 2018-04-13 18:32:20 +02:00
parent dafb554792
commit 9928521557
2 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,19 @@
const getMana = require('../getMana');
const {rawSql} = require('./helpers');
const model = {
remoteMethod: () => {}
};
rawSql(model);
getMana(model);
describe('client getMana()', () => {
it('should call the getMana method', done => {
model.getMana(101)
.then(response => {
expect(response.mana).toEqual(0);
done();
});
});
});

View File

@ -0,0 +1,14 @@
module.exports.rawSql = Self => {
const DataSource = require('loopback-datasource-juggler').DataSource;
const rawSql = require('../../../../common/methods/vnModel/rawSql.js');
const dataSourceConfig = {
connector: 'mysql',
host: 'localhost',
user: 'root',
password: 'root',
database: 'salix'
};
const dataSource = new DataSource(dataSourceConfig);
Self.dataSource = dataSource;
rawSql(Self);
};