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

38 lines
1.1 KiB
JavaScript
Raw Normal View History

2023-01-12 14:16:38 +00:00
const models = require('vn-loopback/server/server').models;
describe('docuware upload()', () => {
2023-01-12 14:16:38 +00:00
const userId = 9;
const ticketId = 10;
2023-01-12 14:16:38 +00:00
const ctx = {
req: {
getLocale: () => {
return 'en';
},
2023-01-12 14:16:38 +00:00
accessToken: {userId: userId},
headers: {origin: 'http://localhost:5000'},
}
};
const docuwareModel = models.Docuware;
const ticketModel = models.Ticket;
2023-01-12 14:16:38 +00:00
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())));
2023-01-12 14:16:38 +00:00
});
it('should try upload file', async() => {
spyOn(ticketModel, 'deliveryNotePdf').and.returnValue(new Promise(resolve => resolve({})));
2023-01-12 14:16:38 +00:00
let error;
try {
await models.Docuware.upload(ctx, ticketId, fileCabinetName);
2023-01-12 14:16:38 +00:00
} catch (e) {
error = e.message;
}
expect(error).toEqual('Action not allowed on the test environment');
2023-01-12 14:16:38 +00:00
});
});