39 lines
1.2 KiB
JavaScript
39 lines
1.2 KiB
JavaScript
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 = {
|
|
Items: [
|
|
{
|
|
Id: docuwareId,
|
|
Fields: [
|
|
{
|
|
FieldName: 'ESTADO',
|
|
Item: 'Firmado'
|
|
}
|
|
]
|
|
}
|
|
]
|
|
};
|
|
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);
|
|
});
|
|
});
|