letterxpress/test/test.nonci.ts

117 lines
3.1 KiB
TypeScript
Raw Normal View History

2024-02-16 19:27:14 +00:00
import { expect, tap } from '@push.rocks/tapbundle';
2022-06-16 01:29:41 +00:00
import * as letterxpress from '../ts/index.js';
import * as tsclass from '@tsclass/tsclass';
2024-02-16 19:27:14 +00:00
import { Qenv } from '@push.rocks/qenv';
2022-06-16 01:29:41 +00:00
let testQenv = new Qenv('./', './.nogit/');
let testAccount: letterxpress.LetterXpressAccount;
let testLetter: tsclass.business.ILetter;
tap.test('should create a valid account', async () => {
2024-02-17 01:34:31 +00:00
testAccount = await letterxpress.LetterXpressAccount.createAndStart({
2024-02-16 19:27:14 +00:00
apiKey: await testQenv.getEnvVarOnDemand('API_TOKEN'),
username: await testQenv.getEnvVarOnDemand('API_USERNAME'),
2022-06-16 01:29:41 +00:00
});
expect(testAccount).toBeInstanceOf(letterxpress.LetterXpressAccount);
});
tap.test('should send an actual letter', async () => {
testLetter = {
from: {
name: 'Lossless GmbH',
type: 'company',
description: 'a company',
sepaConnection: {
iban: 'NL83 BUNQ 2035 5639 41',
bic: 'BUNQNL2AXXX',
},
address: {
name: 'default',
city: 'Bremen',
country: 'Germany',
postalCode: '28359',
houseNumber: '5',
streetName: 'Karl-Ferdinand-Braun-Str.',
},
},
to: {
name: 'Lossless GmbH',
type: 'company',
description: 'a company',
address: {
city: 'Bremen',
country: 'Germany',
postalCode: '28359',
streetName: 'Karl-Ferdinand-Braun-Str.',
houseNumber: '5',
},
},
incidenceId: 'abc123',
legalContact: {
type: 'company',
salutation: null,
surname: null,
title: null,
address: {
city: 'Bremen',
country: 'Germany',
name: 'Lossless GmbH',
postalCode: '28359',
streetName: 'Karl-Ferdinand-Braun-Str.',
houseNumber: '5',
},
sepaConnection: {
iban: 'NL83 BUNQ 2035 5639 41',
bic: 'BUNQNL2AXXX',
},
customerNumber: null,
description: null,
email: 'hello@lossless.com',
fax: '+49 421 408951 46',
phone: '+49 421 16767 548',
legalEntity: 'Lossless GmbH',
name: 'Lossless GmbH',
vatId: 'DE293580420',
},
subject: 'General Terms - Update',
2024-02-16 19:27:14 +00:00
content: {
textData: [`
To whome it may concern,
**this is a testmessage.** we write to inform you about a change in our General Terms.
As of December 1st 2019 we will start storing IPs that connect to our app for a period of 3 month.
Regards
Lossless GmbH - Legal Department
`],
timesheetData: null,
},
2022-06-16 01:29:41 +00:00
date: Date.now(),
language: 'DE',
logoUrl: '',
needsCoverSheet: true,
objectActions: [],
pdfAttachments: [],
2024-02-16 19:27:14 +00:00
type: 'notice',
versionInfo: {
type: 'final',
version: '1.0.0',
}
2022-06-16 01:29:41 +00:00
};
2024-02-16 19:27:14 +00:00
const result = await testAccount.sendLetter(testLetter);
2022-06-16 01:29:41 +00:00
});
tap.test('should be able to delete the sending job', async (toolsArg) => {
2024-02-16 19:27:14 +00:00
await toolsArg.delayFor(30000);
2022-06-16 01:29:41 +00:00
await testAccount.cancelLetter(testLetter);
});
tap.test('should wrap things up', async () => {
await testAccount.stop();
console.log(testLetter);
});
tap.start();