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;
|
|
|
|
const parentId = 1;
|
|
|
|
|
|
|
|
const child = await app.models.Department.findById(childId);
|
|
|
|
|
|
|
|
expect(child.parentFk).toBeNull();
|
|
|
|
updatedChild = await app.models.Department.moveChild(childId, parentId);
|
|
|
|
|
|
|
|
expect(updatedChild.parentFk).toEqual(1);
|
|
|
|
});
|
|
|
|
});
|