salix/modules/ticket/back/methods/expedition/specs/deleteExpeditions.spec.js

38 lines
1.0 KiB
JavaScript
Raw Normal View History

2022-10-10 10:56:03 +00:00
const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context');
2022-10-10 10:56:03 +00:00
describe('ticket deleteExpeditions()', () => {
beforeAll(async() => {
const activeCtx = {
accessToken: {userId: 9},
http: {
req: {
headers: {origin: 'http://localhost'}
}
}
};
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
});
2022-10-10 10:56:03 +00:00
it('should delete the selected expeditions', async() => {
const tx = await models.Expedition.beginTransaction({});
try {
const options = {transaction: tx};
const expeditionIds = [12, 13];
const result = await models.Expedition.deleteExpeditions(expeditionIds, options);
expect(result.length).toEqual(2);
2022-10-10 10:56:03 +00:00
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});