salix/modules/worker/back/methods/worker/specs/deallocatePDA.spec.js

27 lines
999 B
JavaScript

const models = require('vn-loopback/server/server').models;
describe('Worker deallocatePDA()', () => {
it('should deallocate a worker\'s PDA', async() => {
const tx = await models.Worker.beginTransaction({});
try {
const workerWithPDA = 1;
const PDAWithActiveState = 1;
const options = {transaction: tx};
const ctx = {args: {id: workerWithPDA, pda: PDAWithActiveState}};
await models.Worker.deallocatePDA(ctx, options);
const deviceProduction = await models.DeviceProduction.findById(PDAWithActiveState, null, options);
const deviceProductionUser = await models.DeviceProductionUser
.findById(PDAWithActiveState, null, options);
expect(deviceProduction.stateFk).toEqual('idle');
expect(deviceProductionUser).toBe(null);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});