2022-09-07 11:58:39 +00:00
|
|
|
const models = require('vn-loopback/server/server').models;
|
|
|
|
const axios = require('axios');
|
|
|
|
|
|
|
|
describe('boxing getVideoList()', () => {
|
2022-09-26 12:49:11 +00:00
|
|
|
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};
|
|
|
|
|
2022-09-26 12:49:11 +00:00
|
|
|
const id = 1;
|
|
|
|
const from = 1;
|
|
|
|
const to = 2;
|
2022-09-07 11:58:39 +00:00
|
|
|
|
|
|
|
const response = {
|
|
|
|
data: {
|
2022-09-26 12:49:11 +00:00
|
|
|
videos: [{
|
|
|
|
id: 1,
|
|
|
|
filename: 'video1.mp4'
|
|
|
|
}]
|
2022-09-07 11:58:39 +00:00
|
|
|
}
|
|
|
|
};
|
2022-09-26 12:49:11 +00:00
|
|
|
|
2022-09-07 11:58:39 +00:00
|
|
|
spyOn(axios, 'get').and.returnValue(new Promise(resolve => resolve(response)));
|
|
|
|
|
2022-09-26 12:49:11 +00:00
|
|
|
const result = await models.Boxing.getVideoList(id, from, to, options);
|
2022-09-07 11:58:39 +00:00
|
|
|
|
2022-09-26 12:49:11 +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;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|