#192 refactor on back end unit test helpers to ready loopback methods extensions CR Joan
This commit is contained in:
parent
228239b027
commit
f3eecf53b7
|
@ -1,10 +1,11 @@
|
|||
const getAverageInvoiced = require('../getAverageInvoiced');
|
||||
const {rawSql} = require('../../../test-helpers/rawSql');
|
||||
const model = {
|
||||
remoteMethod: () => {}
|
||||
};
|
||||
let Loopback = require('../../../test-helpers/loopback');
|
||||
Loopback.init(model);
|
||||
|
||||
rawSql(model);
|
||||
Loopback.rawSql(model);
|
||||
getAverageInvoiced(model);
|
||||
|
||||
describe('client getAverageInvoiced()', () => {
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
const getMana = require('../getMana');
|
||||
const {rawSql} = require('../../../test-helpers/rawSql');
|
||||
const model = {
|
||||
remoteMethod: () => {}
|
||||
};
|
||||
let Loopback = require('../../../test-helpers/loopback');
|
||||
Loopback.init(model);
|
||||
|
||||
rawSql(model);
|
||||
Loopback.rawSql(model);
|
||||
getMana(model);
|
||||
|
||||
describe('client getMana()', () => {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
var UserError = require('../../helpers').UserError;
|
||||
let UserError = require('../../helpers').UserError;
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('clone', {
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
const clone = require('../clone');
|
||||
const model = {
|
||||
remoteMethod: () => {}
|
||||
};
|
||||
let Loopback = require('../../../test-helpers/loopback');
|
||||
Loopback.init(model);
|
||||
|
||||
Loopback.rawSql(model);
|
||||
clone(model);
|
||||
|
||||
describe('item clone()', () => {
|
||||
it('should', () => {
|
||||
let itemFk = 1;
|
||||
model.clone(itemFk)
|
||||
.then(response => {
|
||||
expect(response).toEqual('whatever');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
|
@ -25,7 +25,7 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.updateTaxes = async (id, taxes) => {
|
||||
Self.updateTaxes = async(id, taxes) => {
|
||||
let promises = [];
|
||||
for (let tax of taxes) {
|
||||
if (!tax.taxClassFk)
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
const getTaxes = require('../get-taxes');
|
||||
const {rawSql} = require('../../../test-helpers/rawSql');
|
||||
const model = {
|
||||
remoteMethod: () => {}
|
||||
};
|
||||
let Loopback = require('../../../test-helpers/loopback');
|
||||
Loopback.init(model);
|
||||
|
||||
rawSql(model);
|
||||
Loopback.rawSql(model);
|
||||
getTaxes(model);
|
||||
|
||||
describe('ticket getTaxes()', () => {
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
const getTotal = require('../get-total');
|
||||
const {rawSql} = require('../../../test-helpers/rawSql');
|
||||
const model = {
|
||||
remoteMethod: () => {}
|
||||
};
|
||||
let Loopback = require('../../../test-helpers/loopback');
|
||||
Loopback.init(model);
|
||||
|
||||
rawSql(model);
|
||||
Loopback.rawSql(model);
|
||||
getTotal(model);
|
||||
|
||||
describe('ticket getTotal()', () => {
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
const getVolume = require('../get-volume');
|
||||
const {rawSql} = require('../../../test-helpers/rawSql');
|
||||
const model = {
|
||||
remoteMethod: () => {}
|
||||
};
|
||||
let Loopback = require('../../../test-helpers/loopback');
|
||||
Loopback.init(model);
|
||||
|
||||
rawSql(model);
|
||||
Loopback.rawSql(model);
|
||||
getVolume(model);
|
||||
|
||||
describe('ticket getVolume()', () => {
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
module.exports = {
|
||||
importLoopbackModules: function() {
|
||||
this.rawSqlModule = require('../methods/vnModel/rawSql.js');
|
||||
this.findOneModule = require('../methods/vnModel/rawSql.js');
|
||||
},
|
||||
|
||||
/**
|
||||
* Initializes DataSource once
|
||||
* @param {Object} Self - Model
|
||||
*/
|
||||
init: function(Self) {
|
||||
if (!this.dataSource)
|
||||
this.connect();
|
||||
|
||||
Self.dataSource = this.dataSource;
|
||||
|
||||
this.importLoopbackModules();
|
||||
},
|
||||
|
||||
/**
|
||||
* Instantiate Loopback DataSource
|
||||
*/
|
||||
connect: function() {
|
||||
let DataSource = require('loopback-datasource-juggler').DataSource;
|
||||
let dataSourceConfig = {
|
||||
connector: 'mysql',
|
||||
host: 'localhost',
|
||||
user: 'root',
|
||||
password: 'root',
|
||||
database: 'salix'
|
||||
};
|
||||
|
||||
this.dataSource = new DataSource(dataSourceConfig);
|
||||
},
|
||||
|
||||
rawSql: function(Self) {
|
||||
this.rawSqlModule(Self);
|
||||
}
|
||||
};
|
|
@ -1,14 +0,0 @@
|
|||
module.exports.rawSql = Self => {
|
||||
const DataSource = require('loopback-datasource-juggler').DataSource;
|
||||
const rawSql = require('../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);
|
||||
};
|
Loading…
Reference in New Issue