refactor: refs #6235 Fixed tests back

This commit is contained in:
Guillermo Bonet 2024-01-31 13:16:56 +01:00
parent e0d15e572c
commit 851e5cc5af
6 changed files with 7 additions and 21 deletions

View File

@ -1,6 +1,6 @@
import './index'; import './index';
fdescribe('component vnRoleCard', () => { describe('component vnRoleCard', () => {
let controller; let controller;
let $httpBackend; let $httpBackend;

View File

@ -1,6 +1,6 @@
import './index'; import './index';
fdescribe('component vnRoleDescriptor', () => { describe('component vnRoleDescriptor', () => {
let controller; let controller;
let $httpBackend; let $httpBackend;

View File

@ -46,6 +46,6 @@ module.exports = Self => {
if (!isSubordinate || (isHimself && !isTeamBoss)) if (!isSubordinate || (isHimself && !isTeamBoss))
throw new UserError(`You don't have enough privileges`); 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);
}; };
}; };

View File

@ -43,7 +43,7 @@ module.exports = Self => {
workerFk, workerFk,
timed, timed,
direction, direction,
device || null], (device || null)],
myOptions); myOptions);
if (response && response.error) if (response && response.error)

View File

@ -30,7 +30,7 @@ describe('workerTimeControl clockIn()', () => {
try { try {
const options = {transaction: tx}; 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({ const isClockIn = await models.WorkerTimeControl.findOne({
where: { where: {
userFk: workerId userFk: workerId

View File

@ -3,29 +3,15 @@ const LoopBackContext = require('loopback-context');
const UserError = require('vn-loopback/util/user-error'); const UserError = require('vn-loopback/util/user-error');
describe('workerTimeControl login()', () => { 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() => { 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'); expect(response.name).toBe('developer');
}); });
it('should throw UserError if pin is not provided', async() => { it('should throw UserError if pin is not provided', async() => {
try { try {
await models.WorkerTimeControl.login(ctx); await models.WorkerTimeControl.login();
} catch (error) { } catch (error) {
expect(error).toBeInstanceOf(UserError); expect(error).toBeInstanceOf(UserError);
expect(error.message).toBe('Incorrect pin'); expect(error.message).toBe('Incorrect pin');