fixes and refactor in several spec files
This commit is contained in:
parent
ded1ab5d93
commit
6f162c774e
|
@ -1,16 +1,8 @@
|
|||
const getAverageInvoiced = require('../getAverageInvoiced');
|
||||
const model = {
|
||||
remoteMethod: () => {}
|
||||
};
|
||||
let Loopback = require('../../../test-helpers/loopback');
|
||||
Loopback.init(model);
|
||||
|
||||
Loopback.rawSql(model);
|
||||
getAverageInvoiced(model);
|
||||
const app = require(`${servicesDir}/client/server/server`);
|
||||
|
||||
describe('client getAverageInvoiced()', () => {
|
||||
it('should call the getAverageInvoiced method', done => {
|
||||
model.getAverageInvoiced(101)
|
||||
app.models.Client.getAverageInvoiced(101)
|
||||
.then(response => {
|
||||
expect(response.invoiced).toEqual(1500);
|
||||
done();
|
||||
|
|
|
@ -1,16 +1,8 @@
|
|||
const getMana = require('../getMana');
|
||||
const model = {
|
||||
remoteMethod: () => {}
|
||||
};
|
||||
let Loopback = require('../../../test-helpers/loopback');
|
||||
Loopback.init(model);
|
||||
|
||||
Loopback.rawSql(model);
|
||||
getMana(model);
|
||||
const app = require(`${servicesDir}/client/server/server`);
|
||||
|
||||
describe('client getMana()', () => {
|
||||
it('should call the getMana method', done => {
|
||||
model.getMana(101)
|
||||
app.models.Client.getMana(101)
|
||||
.then(response => {
|
||||
expect(response.mana).toEqual(30.02);
|
||||
done();
|
||||
|
|
|
@ -1,16 +1,8 @@
|
|||
const getTaxes = require('../get-taxes');
|
||||
const model = {
|
||||
remoteMethod: () => {}
|
||||
};
|
||||
let Loopback = require('../../../test-helpers/loopback');
|
||||
Loopback.init(model);
|
||||
|
||||
Loopback.rawSql(model);
|
||||
getTaxes(model);
|
||||
const app = require(`${servicesDir}/ticket/server/server`);
|
||||
|
||||
describe('ticket getTaxes()', () => {
|
||||
it('should call the getTaxes method', done => {
|
||||
model.getTaxes(1)
|
||||
app.models.Ticket.getTaxes(1)
|
||||
.then(response => {
|
||||
expect(response[0].tax).toEqual(1.05);
|
||||
done();
|
||||
|
|
|
@ -1,16 +1,8 @@
|
|||
const getTotal = require('../get-total');
|
||||
const model = {
|
||||
remoteMethod: () => {}
|
||||
};
|
||||
let Loopback = require('../../../test-helpers/loopback');
|
||||
Loopback.init(model);
|
||||
|
||||
Loopback.rawSql(model);
|
||||
getTotal(model);
|
||||
const app = require(`${servicesDir}/ticket/server/server`);
|
||||
|
||||
describe('ticket getTotal()', () => {
|
||||
it('should call the getTotal method and return the response', done => {
|
||||
model.getTotal(1)
|
||||
app.models.Ticket.getTotal(1)
|
||||
.then(response => {
|
||||
expect(response).toEqual(11.55);
|
||||
done();
|
||||
|
@ -18,7 +10,7 @@ describe('ticket getTotal()', () => {
|
|||
});
|
||||
|
||||
it(`should call the getTotal method and return zero if doesn't have lines`, done => {
|
||||
model.getTotal(13)
|
||||
app.models.Ticket.getTotal(13)
|
||||
.then(response => {
|
||||
expect(response).toEqual(0);
|
||||
done();
|
||||
|
|
|
@ -1,17 +1,9 @@
|
|||
const getVolume = require('../get-volume');
|
||||
const model = {
|
||||
remoteMethod: () => {}
|
||||
};
|
||||
let Loopback = require('../../../test-helpers/loopback');
|
||||
Loopback.init(model);
|
||||
|
||||
Loopback.rawSql(model);
|
||||
getVolume(model);
|
||||
const app = require(`${servicesDir}/ticket/server/server`);
|
||||
|
||||
describe('ticket getVolume()', () => {
|
||||
it('should call the getVolume method', done => {
|
||||
let ticketFk = 1;
|
||||
model.getVolume(ticketFk)
|
||||
app.models.Ticket.getVolume(ticketFk)
|
||||
.then(response => {
|
||||
expect(response[0][0].m3_total).toEqual(0.008);
|
||||
done();
|
||||
|
|
|
@ -1,22 +1,12 @@
|
|||
/* let Jasmine = require('jasmine');
|
||||
const {getTicketData} = require('../summary');
|
||||
// const app = require(`${servicesDir}/ticket/server/server`);
|
||||
|
||||
const summary = require('../summary');
|
||||
const model = {
|
||||
remoteMethod: () => {}
|
||||
};
|
||||
// fdescribe('ticket summary()', () => {
|
||||
// describe('getTicketData()', () => {
|
||||
// it('should sum all sales price', done => {
|
||||
// let result = getTicketData(model, 1);
|
||||
|
||||
summary(model);
|
||||
|
||||
fdescribe('ticket summary()', () => {
|
||||
describe('getTicketData()', () => {
|
||||
it('should sum all sales price', done => {
|
||||
let result = getTicketData(model, 1);
|
||||
|
||||
expect(result).toEqual("pepinillos");
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
*/
|
||||
// expect(result).toEqual("pepinillos");
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
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);
|
||||
}
|
||||
};
|
|
@ -9,6 +9,7 @@ var verbose = false;
|
|||
if (process.argv[2] === '--v') {
|
||||
verbose = true;
|
||||
}
|
||||
servicesDir = `${__dirname}/services`;
|
||||
|
||||
var Jasmine = require('jasmine');
|
||||
var jasmine = new Jasmine();
|
||||
|
|
Loading…
Reference in New Issue