5334-editDepartment #1521

Merged
carlossa merged 84 commits from 5334-editDepartment into dev 2023-07-06 07:09:06 +00:00
2 changed files with 9 additions and 3 deletions
Showing only changes of commit a155f846c2 - Show all commits

View File

@ -1,5 +1,5 @@
module.exports = Self => {
Self.remoteMethodCtx, ('getLeaves', {
Self.remoteMethodCtx('getLeaves', {
description: 'Returns the nodes for a department',
accepts: [{
arg: 'parentId',
@ -21,10 +21,15 @@ module.exports = Self => {
});
Self.getLeaves = async(ctx, parentId = null, search) => {
const myOptions = {userId: ctx.req.accessToken.userId};
if (typeof options == 'object')
Object.assign(myOptions, options);
let [res] = await Self.rawSql(
`CALL department_getLeaves(?, ?)`,
[parentId, search],
{userId: ctx.req.accessToken.userId}
myOptions
);
let map = new Map();

View File

@ -1,8 +1,9 @@
const models = require('vn-loopback/server/server').models;
describe('department getLeaves()', () => {
const ctx = {req: {accessToken: {userId: 9}}};
it('should return the department and the childs containing the search value', async() => {
let result = await models.Department.getLeaves(null, 'INFORMATICA');
let result = await models.Department.getLeaves(ctx, null, 'INFORMATICA');
expect(result.length).toEqual(1);
});