const models = require('vn-loopback/server/server').models; describe('docuware upload()', () => { const userId = 9; const ticketIds = [10]; const ctx = { args: {ticketIds}, req: { getLocale: () => { return 'en'; }, accessToken: {userId: userId}, headers: {origin: 'http://localhost:5000'}, } }; const docuwareModel = models.Docuware; const ticketModel = models.Ticket; const fileCabinetName = 'deliveryNote'; beforeAll(() => { spyOn(docuwareModel, 'getFileCabinet').and.returnValue(new Promise(resolve => resolve(Math.random()))); spyOn(docuwareModel, 'getDialog').and.returnValue(new Promise(resolve => resolve(Math.random()))); }); it('should try upload file', async() => { spyOn(ticketModel, 'deliveryNotePdf').and.returnValue(new Promise(resolve => resolve({}))); let error; try { await models.Docuware.upload(ctx, ticketIds, fileCabinetName); } catch (e) { error = e.message; } expect(error).toEqual('Action not allowed on the test environment'); }); });