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`);
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}}};
app.models.Message.send('salesPerson', {message: 'I changed something'}, ctx)
await app.models.Message.send('salesPerson', {message: 'I changed something'}, ctx)
.then(response => {
expect(response.sent).toEqual(1);
done();
});
});
});

View File

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

View File

@ -23,7 +23,7 @@ module.exports = function(Self) {
Self.changeState = function(ctx, state, cb) {
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) {
if (err)
@ -32,7 +32,7 @@ module.exports = function(Self) {
changeState(emp.id, tickets, state, cb);
});
Self.disconnectFromService("client");
Self.disconnectFromService('client');
};
function changeState(emp, tickets, state, cb) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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