renamed spec files accordingly plus linter and indentation corrections

This commit is contained in:
Carlos Jimenez 2018-08-01 14:01:42 +02:00
parent b5356eb07d
commit d799ac8100
10 changed files with 22 additions and 31 deletions

View File

@ -1,12 +1,11 @@
const app = require(`${servicesDir}/client/server/server`); const app = require(`${servicesDir}/client/server/server`);
describe('message send()', () => { describe('message send()', () => {
it('should call the send method and return the response', done => { it('should call the send method and return the response', async() => {
let ctx = {req: {accessToken: {userId: 1}}}; let ctx = {req: {accessToken: {userId: 1}}};
app.models.Message.send('salesPerson', {message: 'I changed something'}, ctx) await app.models.Message.send('salesPerson', {message: 'I changed something'}, ctx)
.then(response => { .then(response => {
expect(response.sent).toEqual(1); expect(response.sent).toEqual(1);
done();
}); });
}); });
}); });

View File

@ -1,4 +1,4 @@
module.exports = State => { module.exports = State => {
var serverFilter = {where: {order: {gt: 0}}, order: "order, name"}; var serverFilter = {where: {order: {gt: 0}}, order: 'order, name'};
State.defineScope(serverFilter); State.defineScope(serverFilter);
}; };

View File

@ -23,7 +23,7 @@ module.exports = function(Self) {
Self.changeState = function(ctx, state, cb) { Self.changeState = function(ctx, state, cb) {
var tickets = ctx.req.body.tickets; var tickets = ctx.req.body.tickets;
Self.connectToService(ctx, "client"); Self.connectToService(ctx, 'client');
Self.app.models.Worker.findOne({where: {userFk: ctx.req.accessToken.userId}}, function(err, emp) { Self.app.models.Worker.findOne({where: {userFk: ctx.req.accessToken.userId}}, function(err, emp) {
if (err) if (err)
@ -32,7 +32,7 @@ module.exports = function(Self) {
changeState(emp.id, tickets, state, cb); changeState(emp.id, tickets, state, cb);
}); });
Self.disconnectFromService("client"); Self.disconnectFromService('client');
}; };
function changeState(emp, tickets, state, cb) { function changeState(emp, tickets, state, cb) {

View File

@ -1,7 +1,7 @@
const app = require(`${servicesDir}/ticket/server/server`); const app = require(`${servicesDir}/ticket/server/server`);
describe('ticket componentUpdate()', () => { describe('ticket componentUpdate()', () => {
it('should call the componentUpdate method', done => { it('should call the componentUpdate method and receive an error', async() => {
let data = { let data = {
agencyModeFk: 1, agencyModeFk: 1,
addressFk: 121, addressFk: 121,
@ -12,10 +12,9 @@ describe('ticket componentUpdate()', () => {
option: 1 option: 1
}; };
let ctx = {req: {accessToken: {userId: 101}}}; let ctx = {req: {accessToken: {userId: 101}}};
app.models.Ticket.componentUpdate(1, data, ctx) await app.models.Ticket.componentUpdate(1, data, ctx)
.catch(response => { .catch(response => {
expect(response).toEqual(new Error('ER_SIGNAL_EXCEPTION: NO_AGENCY_AVAILABLE')); expect(response).toEqual(new Error('ER_SIGNAL_EXCEPTION: NO_AGENCY_AVAILABLE'));
done();
}); });
}); });
}); });

View File

@ -1,16 +1,15 @@
const app = require(`${servicesDir}/ticket/server/server`); const app = require(`${servicesDir}/ticket/server/server`);
describe('ticket getShipped()', () => { describe('ticket getShipped()', () => {
it('should call the getShipped method', done => { it('should call the getShipped method', async() => {
let data = { let data = {
landed: new Date(), landed: new Date(),
addressFk: 121, addressFk: 121,
agencyModeFk: 7 agencyModeFk: 7
}; };
app.models.Ticket.getShipped(data) await app.models.Ticket.getShipped(data)
.then(response => { .then(response => {
expect(response.warehouseFk).toEqual(1); expect(response.warehouseFk).toEqual(1);
done();
}); });
}); });
}); });

View File

@ -1,11 +1,10 @@
const app = require(`${servicesDir}/ticket/server/server`); const app = require(`${servicesDir}/ticket/server/server`);
describe('ticket getTaxes()', () => { describe('ticket getTaxes()', () => {
it('should call the getTaxes method', done => { it('should call the getTaxes method', async() => {
app.models.Ticket.getTaxes(1) await app.models.Ticket.getTaxes(1)
.then(response => { .then(response => {
expect(response[0].tax).toEqual(20.95); expect(response[0].tax).toEqual(20.95);
done();
}); });
}); });
}); });

View File

@ -1,19 +1,17 @@
const app = require(`${servicesDir}/ticket/server/server`); const app = require(`${servicesDir}/ticket/server/server`);
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', async() => {
app.models.Ticket.getTotal(1) await app.models.Ticket.getTotal(1)
.then(response => { .then(response => {
expect(response).toEqual(448.25); expect(response).toEqual(448.25);
done();
}); });
}); });
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`, async() => {
app.models.Ticket.getTotal(13) await app.models.Ticket.getTotal(13)
.then(response => { .then(response => {
expect(response).toEqual(0); expect(response).toEqual(0);
done();
}); });
}); });
}); });

View File

@ -1,19 +1,17 @@
const app = require(`${servicesDir}/ticket/server/server`); const app = require(`${servicesDir}/ticket/server/server`);
describe('ticket getVAT()', () => { describe('ticket getVAT()', () => {
it('should call the getVAT method and return the response', done => { it('should call the getVAT method and return the response', async() => {
app.models.Ticket.getVAT(1) await app.models.Ticket.getVAT(1)
.then(response => { .then(response => {
expect(response).toEqual(58.75); expect(response).toEqual(58.75);
done();
}); });
}); });
it(`should call the getVAT method and return zero if doesn't have lines`, done => { it(`should call the getVAT method and return zero if doesn't have lines`, async() => {
app.models.Ticket.getVAT(13) await app.models.Ticket.getVAT(13)
.then(response => { .then(response => {
expect(response).toEqual(0); expect(response).toEqual(0);
done();
}); });
}); });
}); });

View File

@ -1,12 +1,11 @@
const app = require(`${servicesDir}/ticket/server/server`); const app = require(`${servicesDir}/ticket/server/server`);
describe('ticket getVolume()', () => { describe('ticket getVolume()', () => {
it('should call the getVolume method', done => { it('should call the getVolume method', async() => {
let ticketFk = 1; let ticketFk = 1;
app.models.Ticket.getVolume(ticketFk) await app.models.Ticket.getVolume(ticketFk)
.then(response => { .then(response => {
expect(response[0].m3).toEqual(0.04); expect(response[0].m3).toEqual(0.04);
done();
}); });
}); });
}); });

View File

@ -1,3 +1,3 @@
module.exports = Self => { module.exports = Self => {
require('../methods/message/send')(Self); require('../methods/message/send')(Self);
} };