salix/modules/worker/back/methods/department/specs/moveChild.spec.js

23 lines
670 B
JavaScript
Raw Normal View History

2019-10-17 11:27:50 +00:00
const app = require('vn-loopback/server/server');
describe('department moveChild()', () => {
let updatedChild;
afterAll(async() => {
2019-10-17 11:27:50 +00:00
const child = await app.models.Department.findById(updatedChild.id);
await child.updateAttribute('parentFk', null);
});
it('should move a child department to a new parent', async() => {
const childId = 22;
2022-02-23 08:05:53 +00:00
const parentId = 37;
2019-10-17 11:27:50 +00:00
const child = await app.models.Department.findById(childId);
2022-02-23 08:05:53 +00:00
expect(child.parentFk).toEqual(1);
2019-10-17 11:27:50 +00:00
updatedChild = await app.models.Department.moveChild(childId, parentId);
2022-02-23 08:05:53 +00:00
expect(updatedChild.parentFk).toEqual(37);
2019-10-17 11:27:50 +00:00
});
});