delete testBack
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
9094c4f1cb
commit
c105316a04
|
@ -1,71 +0,0 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
describe('InvoiceOut downloadZip()', () => {
|
||||
const userId = 9;
|
||||
const invoiceIds = '1,2';
|
||||
const ctx = {
|
||||
req: {
|
||||
|
||||
accessToken: {userId: userId},
|
||||
headers: {origin: 'http://localhost:5000'},
|
||||
}
|
||||
};
|
||||
|
||||
it('should return part of link to dowloand the zip', async() => {
|
||||
const tx = await models.InvoiceOut.beginTransaction({});
|
||||
|
||||
const promise = new Promise(resolve => resolve('streamObject'));
|
||||
promise.path = 'storage/pdfs/invoice/2001/1/1/2001T4444444.pdf';
|
||||
|
||||
spyOn(models.InvoiceOut, 'download').and.returnValue([
|
||||
promise,
|
||||
'application/pdf',
|
||||
'filename="2001T1111111.pdf"'
|
||||
]);
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const result = await models.InvoiceOut.downloadZip(ctx, invoiceIds, options);
|
||||
|
||||
expect(result).toBeDefined();
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
it('should return an error if the size of the files is too large', async() => {
|
||||
const tx = await models.InvoiceOut.beginTransaction({});
|
||||
|
||||
const promise = new Promise(resolve => resolve('streamObject'));
|
||||
promise.path = 'storage/pdfs/invoice/2001/1/1/2001T4444444.pdf';
|
||||
|
||||
spyOn(models.InvoiceOut, 'download').and.returnValue([
|
||||
promise,
|
||||
'application/pdf',
|
||||
'filename="2001T1111111.pdf"'
|
||||
]);
|
||||
|
||||
let error;
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
const zipConfig = {
|
||||
maxSize: 0
|
||||
};
|
||||
await models.ZipConfig.create(zipConfig, options);
|
||||
|
||||
await models.InvoiceOut.downloadZip(ctx, invoiceIds, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
error = e;
|
||||
}
|
||||
|
||||
expect(error).toEqual(new UserError(`Files are too large`));
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue