salix/back/methods/docuware/specs/checkFile.spec.js

39 lines
1.2 KiB
JavaScript
Raw Normal View History

const models = require('vn-loopback/server/server').models;
describe('docuware download()', () => {
const ticketId = 1;
2023-01-12 14:16:38 +00:00
const docuwareModel = models.Docuware;
const fileCabinetName = 'deliveryNote';
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
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;
const response = {
2023-07-05 10:09:52 +00:00
Items: [
{
Id: docuwareId,
Fields: [
{
FieldName: 'ESTADO',
Item: 'Firmado'
}
]
}
]
2023-01-12 14:16:38 +00:00
};
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
});