const models = require('vn-loopback/server/server').models; describe('docuware download()', () => { const ticketId = 1; const docuwareModel = models.Docuware; const fileCabinetName = 'deliveryNote'; it('should return false if there are no documents', async() => { spyOn(docuwareModel, 'get').and.returnValue((new Promise(resolve => resolve({Items: []})))); const result = await models.Docuware.checkFile(ticketId, fileCabinetName, null, true); expect(result).toEqual(false); }); it('should return the document data', async() => { const docuwareId = 1; const response = [{ 'Document ID': docuwareId }]; spyOn(docuwareModel, 'get').and.returnValue((new Promise(resolve => resolve(response)))); const result = await models.Docuware.checkFile(ticketId, fileCabinetName, null, true); expect(result.id).toEqual(docuwareId); }); });