2022-10-10 10:56:03 +00:00
|
|
|
const models = require('vn-loopback/server/server').models;
|
2023-04-12 10:33:14 +00:00
|
|
|
const LoopBackContext = require('loopback-context');
|
2022-10-10 10:56:03 +00:00
|
|
|
|
|
|
|
describe('ticket deleteExpeditions()', () => {
|
2023-11-23 10:21:56 +00:00
|
|
|
let ctx;
|
2023-04-12 10:33:14 +00:00
|
|
|
beforeAll(async() => {
|
2023-11-23 10:21:56 +00:00
|
|
|
ctx = {
|
2023-04-12 10:33:14 +00:00
|
|
|
accessToken: {userId: 9},
|
2023-11-23 10:21:56 +00:00
|
|
|
req: {
|
|
|
|
headers: {origin: 'http://localhost'}
|
2023-04-12 10:33:14 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
2023-11-23 10:21:56 +00:00
|
|
|
active: ctx
|
2023-04-12 10:33:14 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
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];
|
2023-11-23 10:21:56 +00:00
|
|
|
const result = await models.Expedition.deleteExpeditions(ctx, expeditionIds, options);
|
2022-10-10 10:56:03 +00:00
|
|
|
|
2022-10-26 06:39:07 +00:00
|
|
|
expect(result.length).toEqual(2);
|
2022-10-10 10:56:03 +00:00
|
|
|
|
|
|
|
await tx.rollback();
|
|
|
|
} catch (e) {
|
|
|
|
await tx.rollback();
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|