2019-10-17 11:27:50 +00:00
|
|
|
const app = require('vn-loopback/server/server');
|
|
|
|
|
|
|
|
describe('department moveChild()', () => {
|
|
|
|
let updatedChild;
|
|
|
|
|
2021-10-15 12:45:41 +00:00
|
|
|
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
|
|
|
});
|
|
|
|
});
|