2022-02-21 07:48:53 +00:00
|
|
|
const models = require('vn-loopback/server/server').models;
|
|
|
|
|
2023-01-13 12:33:59 +00:00
|
|
|
describe('docuware download()', () => {
|
2022-02-21 07:48:53 +00:00
|
|
|
const ticketId = 1;
|
|
|
|
|
2023-01-12 14:16:38 +00:00
|
|
|
const docuwareModel = models.Docuware;
|
|
|
|
const fileCabinetName = 'deliveryNote';
|
2022-02-21 07:48:53 +00:00
|
|
|
|
2023-01-12 14:16:38 +00:00
|
|
|
it('should return false if there are no documents', async() => {
|
2023-07-05 10:09:52 +00:00
|
|
|
spyOn(docuwareModel, 'get').and.returnValue((new Promise(resolve => resolve({Items: []}))));
|
2022-02-16 13:57:47 +00:00
|
|
|
|
2023-07-05 10:09:52 +00:00
|
|
|
const result = await models.Docuware.checkFile(ticketId, fileCabinetName, null, true);
|
2022-02-16 13:57:47 +00:00
|
|
|
|
2022-02-21 07:48:53 +00:00
|
|
|
expect(result).toEqual(false);
|
2022-02-16 13:57:47 +00:00
|
|
|
});
|
2023-01-12 14:16:38 +00:00
|
|
|
|
|
|
|
it('should return the document data', async() => {
|
|
|
|
const docuwareId = 1;
|
2023-08-22 08:17:46 +00:00
|
|
|
const response = [{
|
|
|
|
'Document ID': docuwareId
|
|
|
|
}];
|
2023-07-05 10:09:52 +00:00
|
|
|
spyOn(docuwareModel, 'get').and.returnValue((new Promise(resolve => resolve(response))));
|
2023-01-12 14:16:38 +00:00
|
|
|
|
2023-07-05 10:09:52 +00:00
|
|
|
const result = await models.Docuware.checkFile(ticketId, fileCabinetName, null, true);
|
2023-01-12 14:16:38 +00:00
|
|
|
|
|
|
|
expect(result.id).toEqual(docuwareId);
|
|
|
|
});
|
2022-02-16 13:57:47 +00:00
|
|
|
});
|