refactor: refs #6235 Fixed tests back
This commit is contained in:
parent
e0d15e572c
commit
851e5cc5af
|
@ -1,6 +1,6 @@
|
|||
import './index';
|
||||
|
||||
fdescribe('component vnRoleCard', () => {
|
||||
describe('component vnRoleCard', () => {
|
||||
let controller;
|
||||
let $httpBackend;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import './index';
|
||||
|
||||
fdescribe('component vnRoleDescriptor', () => {
|
||||
describe('component vnRoleDescriptor', () => {
|
||||
let controller;
|
||||
let $httpBackend;
|
||||
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -43,7 +43,7 @@ module.exports = Self => {
|
|||
workerFk,
|
||||
timed,
|
||||
direction,
|
||||
device || null],
|
||||
(device || null)],
|
||||
myOptions);
|
||||
|
||||
if (response && response.error)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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');
|
||||
|
|
Loading…
Reference in New Issue