import { expect, tap } from '@pushrocks/tapbundle'; import * as letterxpress from '../ts/index'; import * as smartletter from '@pushrocks/smartletter'; const smartletterInstance = new smartletter.Smartletter(); let testletter: smartletter.Letter; import { Qenv } from '@pushrocks/qenv'; let testQenv = new Qenv('./', './.nogit/'); let testAccount: letterxpress.LetterXpressAccount; tap.test('start things', async () => { await smartletterInstance.start(); }); tap.test('should create a valid account', async () => { testAccount = new letterxpress.LetterXpressAccount({ apiKey: testQenv.getEnvVarOnDemand('API_TOKEN'), username: testQenv.getEnvVarOnDemand('API_USERNAME') }); expect(testAccount).to.be.instanceOf(letterxpress.LetterXpressAccount); }); 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: `

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` }); 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(); }) tap.start();