salix/modules/ticket/back/methods/boxing/specs/getVideoList.spec.js

37 lines
1003 B
JavaScript
Raw Normal View History

2022-09-07 11:58:39 +00:00
const models = require('vn-loopback/server/server').models;
const axios = require('axios');
describe('boxing getVideoList()', () => {
it('should return video list', async() => {
2022-09-07 11:58:39 +00:00
const tx = await models.PackingSiteConfig.beginTransaction({});
try {
const options = {transaction: tx};
const id = 1;
const from = 1;
const to = 2;
2022-09-07 11:58:39 +00:00
const response = {
data: {
videos: [{
id: 1,
filename: 'video1.mp4'
}]
2022-09-07 11:58:39 +00:00
}
};
2022-09-07 11:58:39 +00:00
spyOn(axios, 'get').and.returnValue(new Promise(resolve => resolve(response)));
const result = await models.Boxing.getVideoList(id, from, to, options);
2022-09-07 11:58:39 +00:00
expect(result[0]).toEqual(response.data.videos[0].filename);
2022-09-07 11:58:39 +00:00
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});