diff --git a/services/loopback/common/methods/message/specs/send.spec.js b/services/loopback/common/methods/message/specs/send.spec.js index ad5ae54c1..869f60987 100644 --- a/services/loopback/common/methods/message/specs/send.spec.js +++ b/services/loopback/common/methods/message/specs/send.spec.js @@ -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(); }); }); }); diff --git a/services/loopback/common/methods/state/list.js b/services/loopback/common/methods/state/list.js index da2c0c9e5..566b576de 100644 --- a/services/loopback/common/methods/state/list.js +++ b/services/loopback/common/methods/state/list.js @@ -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); }; diff --git a/services/loopback/common/methods/ticket-state/changeState.js b/services/loopback/common/methods/ticket-state/changeState.js index 8bdc6ffd5..02bff16f6 100644 --- a/services/loopback/common/methods/ticket-state/changeState.js +++ b/services/loopback/common/methods/ticket-state/changeState.js @@ -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) { diff --git a/services/loopback/common/methods/ticket/specs/componentUpdate.spec.js b/services/loopback/common/methods/ticket/specs/componentUpdate.spec.js index 6634708ec..7f5a1bd77 100644 --- a/services/loopback/common/methods/ticket/specs/componentUpdate.spec.js +++ b/services/loopback/common/methods/ticket/specs/componentUpdate.spec.js @@ -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(); }); }); }); diff --git a/services/loopback/common/methods/ticket/specs/get-shipped.spec.js b/services/loopback/common/methods/ticket/specs/getShipped.spec.js similarity index 73% rename from services/loopback/common/methods/ticket/specs/get-shipped.spec.js rename to services/loopback/common/methods/ticket/specs/getShipped.spec.js index edee09174..af98d040c 100644 --- a/services/loopback/common/methods/ticket/specs/get-shipped.spec.js +++ b/services/loopback/common/methods/ticket/specs/getShipped.spec.js @@ -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(); }); }); }); diff --git a/services/loopback/common/methods/ticket/specs/get-taxes.spec.js b/services/loopback/common/methods/ticket/specs/getTaxes.spec.js similarity index 65% rename from services/loopback/common/methods/ticket/specs/get-taxes.spec.js rename to services/loopback/common/methods/ticket/specs/getTaxes.spec.js index c65907d8b..a4d9214f9 100644 --- a/services/loopback/common/methods/ticket/specs/get-taxes.spec.js +++ b/services/loopback/common/methods/ticket/specs/getTaxes.spec.js @@ -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(); }); }); }); diff --git a/services/loopback/common/methods/ticket/specs/get-total.spec.js b/services/loopback/common/methods/ticket/specs/getTotal.spec.js similarity index 72% rename from services/loopback/common/methods/ticket/specs/get-total.spec.js rename to services/loopback/common/methods/ticket/specs/getTotal.spec.js index e4553e8ee..50aa5abd8 100644 --- a/services/loopback/common/methods/ticket/specs/get-total.spec.js +++ b/services/loopback/common/methods/ticket/specs/getTotal.spec.js @@ -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(); }); }); }); diff --git a/services/loopback/common/methods/ticket/specs/get-VAT.spec.js b/services/loopback/common/methods/ticket/specs/getVAT.spec.js similarity index 73% rename from services/loopback/common/methods/ticket/specs/get-VAT.spec.js rename to services/loopback/common/methods/ticket/specs/getVAT.spec.js index 4280fc3ba..13b6473c2 100644 --- a/services/loopback/common/methods/ticket/specs/get-VAT.spec.js +++ b/services/loopback/common/methods/ticket/specs/getVAT.spec.js @@ -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(); }); }); }); diff --git a/services/loopback/common/methods/ticket/specs/get-volume.spec.js b/services/loopback/common/methods/ticket/specs/getVolume.spec.js similarity index 66% rename from services/loopback/common/methods/ticket/specs/get-volume.spec.js rename to services/loopback/common/methods/ticket/specs/getVolume.spec.js index 25184f65a..a9aa4685f 100644 --- a/services/loopback/common/methods/ticket/specs/get-volume.spec.js +++ b/services/loopback/common/methods/ticket/specs/getVolume.spec.js @@ -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(); }); }); }); diff --git a/services/loopback/common/models/message.js b/services/loopback/common/models/message.js index 2ed34b9a9..6a53476f9 100644 --- a/services/loopback/common/models/message.js +++ b/services/loopback/common/models/message.js @@ -1,3 +1,3 @@ module.exports = Self => { require('../methods/message/send')(Self); -} \ No newline at end of file +};