36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
|
const models = require('vn-loopback/server/server').models;
|
||
|
|
||
|
fdescribe('docuware download()', () => {
|
||
|
const userId = 9;
|
||
|
const ticketId = 1;
|
||
|
const ctx = {
|
||
|
req: {
|
||
|
|
||
|
accessToken: {userId: userId},
|
||
|
headers: {origin: 'http://localhost:5000'},
|
||
|
}
|
||
|
};
|
||
|
|
||
|
const docuwareModel = models.Docuware;
|
||
|
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(docuwareModel, 'checkFile').and.returnValue(false);
|
||
|
spyOn(axios, 'get').and.returnValue(new stream.PassThrough({objectMode: true}));
|
||
|
|
||
|
let error;
|
||
|
try {
|
||
|
await models.Docuware.download(ctx, ticketId, fileCabinetName);
|
||
|
} catch (e) {
|
||
|
error = e.message;
|
||
|
}
|
||
|
|
||
|
expect(error).toEqual('The DOCUWARE PDF document does not exists');
|
||
|
});
|
||
|
});
|