From 851e5cc5afb7eeef4ec8d97e7401c21bc5a55351 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 31 Jan 2024 13:16:56 +0100 Subject: [PATCH] refactor: refs #6235 Fixed tests back --- modules/account/front/role/card/index.spec.js | 2 +- .../front/role/descriptor/index.spec.js | 2 +- .../worker-time-control/addTimeEntry.js | 2 +- .../methods/worker-time-control/clockIn.js | 2 +- .../worker-time-control/specs/clockIn.spec.js | 2 +- .../worker-time-control/specs/login.spec.js | 18 ++---------------- 6 files changed, 7 insertions(+), 21 deletions(-) diff --git a/modules/account/front/role/card/index.spec.js b/modules/account/front/role/card/index.spec.js index f02c08f28..569fe487d 100644 --- a/modules/account/front/role/card/index.spec.js +++ b/modules/account/front/role/card/index.spec.js @@ -1,6 +1,6 @@ import './index'; -fdescribe('component vnRoleCard', () => { +describe('component vnRoleCard', () => { let controller; let $httpBackend; diff --git a/modules/account/front/role/descriptor/index.spec.js b/modules/account/front/role/descriptor/index.spec.js index eafb96727..f3b2e4763 100644 --- a/modules/account/front/role/descriptor/index.spec.js +++ b/modules/account/front/role/descriptor/index.spec.js @@ -1,6 +1,6 @@ import './index'; -fdescribe('component vnRoleDescriptor', () => { +describe('component vnRoleDescriptor', () => { let controller; let $httpBackend; diff --git a/modules/worker/back/methods/worker-time-control/addTimeEntry.js b/modules/worker/back/methods/worker-time-control/addTimeEntry.js index 5dbac51ca..86ef12c49 100644 --- a/modules/worker/back/methods/worker-time-control/addTimeEntry.js +++ b/modules/worker/back/methods/worker-time-control/addTimeEntry.js @@ -46,6 +46,6 @@ module.exports = Self => { if (!isSubordinate || (isHimself && !isTeamBoss)) throw new UserError(`You don't have enough privileges`); - return Self.clockIn(workerId, args.timed, args.direction, myOptions); + return Self.clockIn(workerId, args.timed, args.direction, null, myOptions); }; }; diff --git a/modules/worker/back/methods/worker-time-control/clockIn.js b/modules/worker/back/methods/worker-time-control/clockIn.js index 379e7484d..2bc3f16ac 100644 --- a/modules/worker/back/methods/worker-time-control/clockIn.js +++ b/modules/worker/back/methods/worker-time-control/clockIn.js @@ -43,7 +43,7 @@ module.exports = Self => { workerFk, timed, direction, - device || null], + (device || null)], myOptions); if (response && response.error) diff --git a/modules/worker/back/methods/worker-time-control/specs/clockIn.spec.js b/modules/worker/back/methods/worker-time-control/specs/clockIn.spec.js index 9cd3ed1c0..ff4cac7b7 100644 --- a/modules/worker/back/methods/worker-time-control/specs/clockIn.spec.js +++ b/modules/worker/back/methods/worker-time-control/specs/clockIn.spec.js @@ -30,7 +30,7 @@ describe('workerTimeControl clockIn()', () => { try { const options = {transaction: tx}; - await models.WorkerTimeControl.clockIn(workerId, inTime, 'in', options); + await models.WorkerTimeControl.clockIn(workerId, inTime, 'in', 'test', options); const isClockIn = await models.WorkerTimeControl.findOne({ where: { userFk: workerId diff --git a/modules/worker/back/methods/worker-time-control/specs/login.spec.js b/modules/worker/back/methods/worker-time-control/specs/login.spec.js index d9f2dbb39..e125a876d 100644 --- a/modules/worker/back/methods/worker-time-control/specs/login.spec.js +++ b/modules/worker/back/methods/worker-time-control/specs/login.spec.js @@ -3,29 +3,15 @@ const LoopBackContext = require('loopback-context'); const UserError = require('vn-loopback/util/user-error'); describe('workerTimeControl login()', () => { - let ctx; - beforeAll(async() => { - ctx = { - accessToken: {userId: 9}, - req: { - headers: {origin: 'http://localhost'}, - __: key => key - } - }; - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: ctx - }); - }); - it('should correctly login', async() => { - const response = await models.WorkerTimeControl.login(ctx, 9); + const response = await models.WorkerTimeControl.login(9); expect(response.name).toBe('developer'); }); it('should throw UserError if pin is not provided', async() => { try { - await models.WorkerTimeControl.login(ctx); + await models.WorkerTimeControl.login(); } catch (error) { expect(error).toBeInstanceOf(UserError); expect(error.message).toBe('Incorrect pin');