fix(core): update
This commit is contained in:
3
test/paths.ts
Normal file
3
test/paths.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import * as plugins from './plugins.js';
|
||||
|
||||
export const nogitDir = plugins.path.join(process.cwd(), '.nogit');
|
9
test/plugins.ts
Normal file
9
test/plugins.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import * as tsclass from '@tsclass/tsclass';
|
||||
import * as smartfile from '@push.rocks/smartfile';
|
||||
import * as path from 'path';
|
||||
|
||||
export {
|
||||
tsclass,
|
||||
smartfile,
|
||||
path,
|
||||
}
|
152
test/test.ts
Normal file
152
test/test.ts
Normal file
@ -0,0 +1,152 @@
|
||||
import * as plugins from './plugins.js';
|
||||
import * as paths from './paths.js';
|
||||
import { expect, tap } from '@push.rocks/tapbundle';
|
||||
import * as deesDocumentServer from '../ts/index.js';
|
||||
|
||||
let testPdfServiceInstance: deesDocumentServer.PdfService;
|
||||
const testLetterData: plugins.tsclass.business.ILetter = {
|
||||
accentColor: null,
|
||||
type: 'invoice',
|
||||
date: null,
|
||||
needsCoverSheet: true,
|
||||
objectActions: [],
|
||||
pdf: null,
|
||||
content: {
|
||||
invoiceData: {
|
||||
id: 'XX-CLIENT-48765',
|
||||
reverseCharge: true,
|
||||
dueInDays: 30,
|
||||
billedBy: {
|
||||
address: null,
|
||||
description: null,
|
||||
name: 'Some Service GmbH',
|
||||
type: null,
|
||||
customerNumber: null,
|
||||
email: null,
|
||||
facebookUrl: null,
|
||||
fax: null,
|
||||
legalEntity: null,
|
||||
sepaConnection: {
|
||||
bic: 'BPOTBEB1',
|
||||
iban: 'BE72000000001616',
|
||||
},
|
||||
},
|
||||
billedTo: null,
|
||||
status: null,
|
||||
deliveryDate: new Date().getTime(),
|
||||
periodOfPerformance: null,
|
||||
printResult: null,
|
||||
items: [
|
||||
{
|
||||
name: 'Website Creation',
|
||||
unitQuantity: 1,
|
||||
unitNetPrice: 1200,
|
||||
unitType: 'item',
|
||||
vatPercentage: 0,
|
||||
currency: 'EUR',
|
||||
},
|
||||
],
|
||||
},
|
||||
contractData: {
|
||||
contractDate: Date.now(),
|
||||
id: 'LL-CONTRACT-48765',
|
||||
},
|
||||
textData: [],
|
||||
timesheetData: '',
|
||||
},
|
||||
from: {
|
||||
name: 'PdfService Test Company',
|
||||
type: 'company',
|
||||
description: 'doing pdf stuff',
|
||||
address: {
|
||||
streetName: 'Awesome Street',
|
||||
houseNumber: '5',
|
||||
city: 'Bremen',
|
||||
country: 'Germany',
|
||||
postalCode: '28359',
|
||||
},
|
||||
sepaConnection: {
|
||||
bic: 'BPOTBEB1',
|
||||
iban: 'BE72000000001616',
|
||||
},
|
||||
},
|
||||
to: {
|
||||
name: 'Awesome To Company',
|
||||
type: 'company',
|
||||
description: 'a company that does stuff',
|
||||
address: {
|
||||
streetName: 'Awesome Street',
|
||||
houseNumber: '5',
|
||||
city: 'Bremen',
|
||||
country: 'Germany',
|
||||
postalCode: '28359',
|
||||
},
|
||||
},
|
||||
incidenceId: null,
|
||||
language: null,
|
||||
legalContact: null,
|
||||
logoUrl: null,
|
||||
pdfAttachments: null,
|
||||
subject: 'Invoice XX-CLIENT-48765',
|
||||
versionInfo: {
|
||||
type: 'final',
|
||||
version: '1.0.0',
|
||||
},
|
||||
};
|
||||
|
||||
tap.test('should create a document from an invoice', async () => {
|
||||
testPdfServiceInstance = new deesDocumentServer.PdfService({});
|
||||
await testPdfServiceInstance.start();
|
||||
expect(testPdfServiceInstance).toBeInstanceOf(deesDocumentServer.PdfService);
|
||||
});
|
||||
|
||||
tap.test('should create an invoice', async () => {
|
||||
let counter = 0;
|
||||
const saveResult = async (letterDataArg: plugins.tsclass.business.ILetter) => {
|
||||
const pdfResult = await testPdfServiceInstance.createPdfFromLetterObject(letterDataArg);
|
||||
await plugins.smartfile.memory.toFs(Buffer.from(pdfResult.buffer), plugins.path.join(paths.nogitDir, `test-${counter++}.pdf`));
|
||||
}
|
||||
await saveResult(testLetterData);
|
||||
await saveResult({
|
||||
...testLetterData,
|
||||
versionInfo: {
|
||||
type: 'draft',
|
||||
version: '1.0.0',
|
||||
}
|
||||
});
|
||||
testLetterData.content.invoiceData.items = [
|
||||
{
|
||||
name: 'Website Creation',
|
||||
unitQuantity: 1,
|
||||
unitNetPrice: 1200,
|
||||
unitType: 'item',
|
||||
vatPercentage: 0,
|
||||
currency: 'EUR',
|
||||
},
|
||||
{
|
||||
name: 'Hosting',
|
||||
unitQuantity: 1,
|
||||
unitNetPrice: 1200,
|
||||
unitType: 'item',
|
||||
vatPercentage: 19,
|
||||
currency: 'EUR',
|
||||
},
|
||||
{
|
||||
name: 'Overnight Shipping',
|
||||
unitQuantity: 1,
|
||||
unitNetPrice: 1200,
|
||||
unitType: 'item',
|
||||
vatPercentage: 24,
|
||||
currency: 'EUR',
|
||||
},
|
||||
],
|
||||
await saveResult({
|
||||
...testLetterData,
|
||||
})
|
||||
});
|
||||
|
||||
tap.test('should stop the service', async () => {
|
||||
await testPdfServiceInstance.stop();
|
||||
});
|
||||
|
||||
tap.start();
|
Reference in New Issue
Block a user