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