2019-11-13 16:21:52 +00:00
|
|
|
import { expect, tap } from '@pushrocks/tapbundle';
|
|
|
|
import * as letterxpress from '../ts/index';
|
|
|
|
|
2019-11-22 14:02:56 +00:00
|
|
|
import * as smartletter from '@pushrocks/smartletter';
|
|
|
|
const smartletterInstance = new smartletter.Smartletter();
|
|
|
|
let testletter: smartletter.Letter;
|
|
|
|
|
|
|
|
|
2019-11-18 16:18:58 +00:00
|
|
|
import { Qenv } from '@pushrocks/qenv';
|
|
|
|
let testQenv = new Qenv('./', './.nogit/');
|
|
|
|
|
2019-11-18 14:54:40 +00:00
|
|
|
let testAccount: letterxpress.LetterXpressAccount;
|
|
|
|
|
2019-11-22 14:02:56 +00:00
|
|
|
tap.test('start things', async () => {
|
|
|
|
await smartletterInstance.start();
|
|
|
|
});
|
|
|
|
|
2019-11-18 14:54:40 +00:00
|
|
|
tap.test('should create a valid account', async () => {
|
2019-11-18 16:18:58 +00:00
|
|
|
testAccount = new letterxpress.LetterXpressAccount({
|
|
|
|
apiKey: testQenv.getEnvVarOnDemand('API_TOKEN'),
|
2019-11-22 14:02:56 +00:00
|
|
|
username: testQenv.getEnvVarOnDemand('API_USERNAME')
|
2019-11-18 16:18:58 +00:00
|
|
|
});
|
2019-11-18 14:54:40 +00:00
|
|
|
expect(testAccount).to.be.instanceOf(letterxpress.LetterXpressAccount);
|
2019-11-13 16:21:52 +00:00
|
|
|
});
|
|
|
|
|
2019-11-22 14:02:56 +00:00
|
|
|
tap.test('should send an actual letter', async () => {
|
|
|
|
testletter = await smartletterInstance.createLetter({
|
|
|
|
from: {
|
|
|
|
name: 'Lossless GmbH',
|
|
|
|
city: 'Bremen',
|
|
|
|
country: 'Germany',
|
|
|
|
postalCode: '28213',
|
|
|
|
houseNumber: '16',
|
|
|
|
streetName: 'Ottilie-Hoffmann-Str.'
|
|
|
|
},
|
|
|
|
to: {
|
|
|
|
name: 'Lossless GmbH',
|
|
|
|
city: 'Berlin',
|
|
|
|
country: 'Germany',
|
|
|
|
postalCode: '10245',
|
|
|
|
houseNumber: '16a, Scanbox #06320',
|
|
|
|
streetName: 'Ehrenbergstr.'
|
|
|
|
},
|
|
|
|
incidenceId: 'abc123',
|
|
|
|
legalInfo: {
|
|
|
|
name: 'Lossless GmbH',
|
|
|
|
status: 'active',
|
|
|
|
contact: {
|
|
|
|
type: 'company',
|
|
|
|
salutation: null,
|
|
|
|
surname: null,
|
|
|
|
title: null,
|
|
|
|
address: {
|
|
|
|
city: 'Bremen',
|
|
|
|
country: 'Germany',
|
|
|
|
houseNumber: '16',
|
|
|
|
name: 'Lossless GmbH',
|
|
|
|
postalCode: '28213',
|
|
|
|
streetName: 'Ottilie-Hoffmann Str.'
|
|
|
|
},
|
|
|
|
bankAccountNumber: 'NL83 BUNQ 2035 5639 41',
|
|
|
|
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'
|
|
|
|
},
|
|
|
|
closedDate: null,
|
|
|
|
foundedDate: null
|
|
|
|
},
|
|
|
|
subject: 'General Terms - Update',
|
|
|
|
text: `<p>To whome it may concern,</p>
|
|
|
|
<p>
|
|
|
|
<strong>this is a testmessage.</strong> 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.
|
|
|
|
<p>
|
|
|
|
|
|
|
|
Regards<br>
|
|
|
|
Lossless GmbH - Legal Department`
|
|
|
|
});
|
|
|
|
await testAccount.sendLetter(testletter);
|
|
|
|
});
|
|
|
|
|
|
|
|
tap.test('should be able to delete the sending job', async () => {
|
|
|
|
await testAccount.cancelLetter(testletter);
|
|
|
|
});
|
|
|
|
|
|
|
|
tap.test('should wrap things up', async () => {
|
|
|
|
await smartletterInstance.stop();
|
|
|
|
})
|
|
|
|
|
2019-11-13 16:21:52 +00:00
|
|
|
tap.start();
|