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