Backend tests fixed

This commit is contained in:
Juan Ferrer 2018-12-21 12:50:28 +01:00
parent 87dec5e8b2
commit 30ab925ed7
90 changed files with 105 additions and 120 deletions

View File

@ -9,7 +9,7 @@ let verbose = false;
if (process.argv[2] === '--v')
verbose = true;
servicesDir = `${__dirname}/services/db`;
serviceRoot = `${__dirname}/services/db`;
let Jasmine = require('jasmine');
let jasmine = new Jasmine();

View File

@ -1,15 +1,15 @@
const app = require(`${servicesDir}/claim/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('Claim importTicketSales()', () => {
let claimEnds;
afterAll(async() => {
afterAll(async () => {
claimEnds.forEach(async line => {
await line.destroy();
});
});
it('should import sales to a claim actions from an specific ticket', async() => {
it('should import sales to a claim actions from an specific ticket', async () => {
let ctx = {req: {accessToken: {userId: 5}}};
claimEnds = await app.models.ClaimEnd.importTicketSales(ctx, {
claimFk: 1,

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/client/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('Client createWithInsurance', () => {
let classificationId;

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/client/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('receipt filter()', () => {
it('should call the filter method', async () => {

View File

@ -1,6 +1,5 @@
const app = require(`../../../ticket/server/server`);
const server = require(`../../../loopback/server/server`);
const ParameterizedSQL = server.loopbackConnector.ParameterizedSQL;
const app = require(`${serviceRoot}/server/server`);
const ParameterizedSQL = require('vn-loopback/node_modules/loopback-connector').ParameterizedSQL;
describe('last_buy_refresh()', () => {
it(`should store some data on cache.last_buy`, async () => {

View File

@ -1,6 +1,5 @@
const app = require(`../../../ticket/server/server`);
const server = require(`../../../loopback/server/server`);
const ParameterizedSQL = server.loopbackConnector.ParameterizedSQL;
const app = require(`${serviceRoot}/server/server`);
const ParameterizedSQL = require('vn-loopback/node_modules/loopback-connector').ParameterizedSQL;
describe('buyUltimate()', () => {
const today = new Date();

View File

@ -1,6 +1,5 @@
const app = require(`../../../ticket/server/server`);
const server = require(`../../../loopback/server/server`);
const ParameterizedSQL = server.loopbackConnector.ParameterizedSQL;
const app = require(`${serviceRoot}/server/server`);
const ParameterizedSQL = require('vn-loopback/node_modules/loopback-connector').ParameterizedSQL;
describe('buyUltimateFromInterval()', () => {
let today;

View File

@ -1,6 +1,5 @@
const app = require(`../../../ticket/server/server`);
const server = require(`../../../loopback/server/server`);
const ParameterizedSQL = server.loopbackConnector.ParameterizedSQL;
const app = require(`${serviceRoot}/server/server`);
const ParameterizedSQL = require('vn-loopback/node_modules/loopback-connector').ParameterizedSQL;
describe('logAddWithUser()', () => {
it('should log any action taken by the user in a table ending in Log', async () => {

View File

@ -1,6 +1,5 @@
const app = require(`../../../ticket/server/server`);
const server = require(`../../../loopback/server/server`);
const ParameterizedSQL = server.loopbackConnector.ParameterizedSQL;
const app = require(`${serviceRoot}/server/server`);
const ParameterizedSQL = require('vn-loopback/node_modules/loopback-connector').ParameterizedSQL;
describe('ticket ticketCalculateClon()', () => {
const today = new Date();

View File

@ -1,6 +1,5 @@
const app = require(`../../../ticket/server/server`);
const server = require(`../../../loopback/server/server`);
const ParameterizedSQL = server.loopbackConnector.ParameterizedSQL;
const app = require(`${serviceRoot}/server/server`);
const ParameterizedSQL = require('vn-loopback/node_modules/loopback-connector').ParameterizedSQL;
describe('ticketComponentUpdateSale()', () => {
it(`should update the sale price when option ONE using the base components and reclaculate only the ones with isRenewable TRUE`, async () => {

View File

@ -1,6 +1,5 @@
const app = require(`../../../ticket/server/server`);
const server = require(`../../../loopback/server/server`);
const ParameterizedSQL = server.loopbackConnector.ParameterizedSQL;
const app = require(`${serviceRoot}/server/server`);
const ParameterizedSQL = require('vn-loopback/node_modules/loopback-connector').ParameterizedSQL;
describe('ticket ticketCreateWithUser()', () => {
const today = new Date();

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/claim/server/server`);
const app = require(`${serviceRoot}/server/server`);
// xcluded waiting for fixtures
xdescribe('claimBeginning', () => {
let ticket;

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/claim/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('Claim Create', () => {
let newDate = new Date();

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/claim/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('claim getSummary()', () => {
it('should return summary with claim, salesClaimed, developments and actions defined ', async() => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/claim/server/server`);
const app = require(`${serviceRoot}/server/server`);
// xcluded waiting for fixtures
xdescribe('regularizeClaim()', () => {
const claimFk = 1;

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/claim/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('Update Claim', () => {
let newDate = new Date();

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/client/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('Client activeWorkersWithRole', () => {
it('should return the sales people as result', async () => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/client/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('Client addressesPropagateRe', () => {
let client;

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/client/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('Client confirmTransaction', () => {
const transactionId = 2;

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/client/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('Client Create', () => {
const clientName = 'Wade';

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/client/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('client getAverageInvoiced()', () => {
it('should call the getAverageInvoiced method', done => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/client/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('Client card', () => {
it('should call the card() method to receive a formated card of Bruce Wayne', async () => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/client/server/server`);
const app = require(`${serviceRoot}/server/server`);
xdescribe('client getDebt()', () => {
it('should return the client debt', async () => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/client/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('client getMana()', () => {
it('should call the getMana method', async() => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/client/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('Client getTransations', () => {
it('should call getTransations() method to receive a list of Web Payments from Bruce Wayne', async() => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/client/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('Client hasCustomerRole', () => {
it('should call the hasCustomerRole() method with a customer id', done => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/client/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('Client isValidClient', () => {
it('should call the isValidClient() method with a client id and receive true', done => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/client/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('Client listWorkers', () => {
it('should call the listWorkers()', done => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/client/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('client summary()', () => {
it('should return a summary object containing data', async () => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/client/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('Client updateFiscalData', () => {
afterAll(async() => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/item/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('item filterItemTags()', () => {
it('should filter ItemTags table', async () => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/item/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('item clone()', () => {
let nextItemId;

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/item/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('item filter()', () => {
it('should return 1 result using filter and tags', async() => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/item/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('item getShipped()', () => {
it('should return 3 entries, the first one with the property balance -100', async() => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/item/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('item getLastEntries()', () => {
it('should return one entry for a given item', async () => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/item/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('item getSummary()', () => {
it('should return summary with item, tags, botanical, niches, available and visible defined ', async() => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/item/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('regularize()', () => {
const itemFk = 1;

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/item/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('item updateTaxes()', () => {
afterAll(async() => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/client/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('message send()', () => {
it('should call the send method and return the response', async() => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/order/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('order catalogFilter()', () => {
it('should return an array of items', async () => {
let filter = {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/order/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('order getTaxes()', () => {
it('should call the getTaxes method and return undefined if its called with a string', async() => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/order/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('order getTotal()', () => {
it('should return the total', async() => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/order/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('order getTotalVolume()', () => {
it('should return the total', async() => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/order/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('order getVAT()', () => {
it('should call the getVAT method and return the response', async() => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/order/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('order getVolumes()', () => {
it('should return the volumes of a given order id', async() => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/order/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('order isEditable()', () => {
it('should return false when the given order is not editable', async() => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/order/server/server`);
const app = require(`${serviceRoot}/server/server`);
let UserError = require('../../../helpers').UserError;
describe('order new()', () => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/order/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('order summary()', () => {
it('should return a summary object containing data from 1 order', async() => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/order/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('Order updateBasicData', () => {
afterAll(async () => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/ticket/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('sale getClaimableFromTicket()', () => {
it('should return the claimable sales of a given ticket', async () => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/ticket/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('sale moveToTicket()', () => {
it('should throw an error if the ticket is not editable', async () => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/ticket/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('sale priceDifference()', () => {
it('should return ticket price differences', async() => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/ticket/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('sale removes()', () => {
let sale;

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/ticket/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('sale reserve()', () => {
afterAll(async() => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/ticket/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('sale updatePrice()', () => {
it('should throw an error if the price is not a number', async() => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/ticket/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('sale updateQuantity()', () => {
it('should throw an error if the quantity is not a number', async() => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/ticket/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('ticket changeState()', () => {
let ticket;

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/ticket/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('ticket componentUpdate()', () => {
let firstvalueBeforeChange;

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/ticket/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('ticket deleted()', () => {
let ticket;

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/ticket/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('ticket filter()', () => {
it('should call the filter method', async () => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/ticket/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('ticket getLanded()', () => {
it('should return a landing date', async() => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/ticket/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('ticket getSales()', () => {
it('should return the sales of a ticket', async () => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/ticket/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('ticket getSalesPersonMana()', () => {
it('should get the mana of a salesperson of a given ticket', async() => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/ticket/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('ticket getShipped()', () => {
it('should return a shipment date', async() => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/ticket/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('ticket getTaxes()', () => {
it('should return the tax of a given ticket', async() => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/ticket/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('ticket getTotal()', () => {
it('should return the total of a ticket', async() => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/ticket/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('ticket getTotalVolume()', () => {
it('should return the total volume of a ticket', async() => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/ticket/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('ticket getVAT()', () => {
it('should call the getVAT method and return the response', async() => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/ticket/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('ticket getVolume()', () => {
it('should call the getVolume method', async() => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/ticket/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('ticket isEditable()', () => {
it('should return false if the ticket given is not editable', async () => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/ticket/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('ticket new()', () => {
let ticket;

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/ticket/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('ticket summary()', () => {
it('should return a summary object containing data from 1 ticket', async() => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/ticket/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('ticket threeLastActive()', () => {
it('should return the last three active tickets', async() => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/ticket/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('userConfig getUserConfig()', () => {
it(`should return the configuration data of a given user`, async() => {

View File

@ -1,4 +1,4 @@
const app = require('../../../../../item/server/server');
const app = require(`${serviceRoot}/server/server`);
describe('Model crud()', () => {
let insertId;

View File

@ -1,4 +1,4 @@
const app = require('../../../../../order/server/server');
const app = require(`${serviceRoot}/server/server`);
describe('Model getSetValues()', () => {
it('should extend getSetValues properties to any model passed', () => {

View File

@ -1,4 +1,4 @@
const app = require('../../../../../item/server/server');
const app = require(`${serviceRoot}/server/server`);
describe('Model rewriteDbError()', () => {
it('should extend rewriteDbError properties to any model passed', () => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/ticket/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('workerMana getCurrentWorkerMana()', () => {
it('should get the mana of the logged worker', async() => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/client/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('loopback model Account', () => {
it('should return true if the user has the given role', async() => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/client/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('loopback model address', () => {
let createdAddressId;

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/ticket/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('loopback model Item', () => {
describe('availableId()', () => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/ticket/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('loopback model State', () => {
describe('isAlertLevelZero()', () => {

View File

@ -1,5 +1,5 @@
const app = require('../../../server/server');
const routes = require('../routes');
const routes = require('../auth');
describe('Auth routes', () => {
beforeEach(async () => {

View File

@ -6,7 +6,6 @@ const DataSource = require('loopback-datasource-juggler').DataSource;
const fs = require('fs-extra');
const i18n = require('i18n');
const path = require('path');
const loopbackConnector = require('loopback-connector');
let _resolveConnector = DataSource._resolveConnector;
DataSource._resolveConnector = function(...args) {

View File

@ -1,4 +1,4 @@
const app = require(`../../../../server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('order addToOrder()', () => {
let rowToDelete;

View File

@ -1,4 +1,4 @@
const app = require(`../../../../server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('order removes()', () => {
let row;

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/ticket/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('ticket listPackaging()', () => {
it('should call the listPackaging method and return the response', async () => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/ticket/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('ticket listSaleTracking()', () => {
it('should call the listSaleTracking method and return the response', async () => {

View File

@ -1,4 +1,4 @@
const app = require(`${servicesDir}/ticket/server/server`);
const app = require(`${serviceRoot}/server/server`);
describe('ticket model TicketTracking', () => {
let ticketTrackingId;

View File

@ -1,4 +1,5 @@
const fs = require('fs-extra');
require('require-yaml');
process.on('warning', warning => {
console.log(warning.name);
console.log(warning.message);
@ -10,28 +11,20 @@ let verbose = false;
if (process.argv[2] === '--v')
verbose = true;
servicesDir = `${__dirname}/services`;
serviceRoot = `${__dirname}/services/loopback`;
let Jasmine = require('jasmine');
let jasmine = new Jasmine();
let SpecReporter = require('jasmine-spec-reporter').SpecReporter;
let serviceList = fs.readdirSync(servicesDir);
let serviceSpecs = [
'auth/server/**/*[sS]pec.js',
'salix/server/**/*[sS]pec.js'
'loopback/server/**/*[sS]pec.js',
'loopback/common/**/*[sS]pec.js'
];
const exclude = ['auth', 'salix'];
for (let service of serviceList) {
try {
let serviceDir = fs.readdirSync(`${servicesDir}/${service}`);
for (let file of serviceDir) {
if (file === 'server' && exclude.indexOf(service) == -1)
serviceSpecs.push(`${service}/common/**/*[sS]pec.js`);
}
} catch (e) {}
}
let services = require(`./services/services.yml`);
for (let service of services)
serviceSpecs.push(`${service}/**/*[sS]pec.js`);
jasmine.loadConfig({
spec_dir: 'services',