Skip to content

Commit e54be88

Browse files
committed
Added contact and email converter tests
1 parent 2fb226c commit e54be88

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

test/api-test.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,43 @@ describe('EmailApi', function () {
401401
expect(dto.body.location).to.be.equal(location);
402402
});
403403

404+
it('Check contact converter #pipeline', async function () {
405+
const surname = 'Cane';
406+
let contactDto = new models.ContactDto();
407+
contactDto.surname = surname;
408+
contactDto.givenName = 'John';
409+
contactDto.gender = 'Male';
410+
contactDto.emailAddresses = [new models.EmailAddress(undefined, undefined, undefined, undefined,
411+
'address@aspose.com')];
412+
contactDto.phoneNumbers = [new models.PhoneNumber(undefined, '+47234325344')];
413+
let mapi = await api.convertContactModelToFile(new requests.ConvertContactModelToFileRequest(
414+
'Msg', contactDto));
415+
let vcard = await api.convertContact(new requests.ConvertContactRequest(
416+
'VCard', 'Msg', mapi.body));
417+
let vcardString = vcard.body.toString();
418+
expect(vcardString).to.include(surname);
419+
let dto = await api.getContactFileAsModel(new requests.GetContactFileAsModelRequest('VCard', vcard.body));
420+
expect(dto.body.surname).to.be.equal(surname);
421+
});
422+
423+
it('Check email converter #pipeline', async function () {
424+
const from = 'from@aspose.com';
425+
let emailDto = new models.EmailDto();
426+
emailDto.from = new models.MailAddress(undefined, from);
427+
emailDto.to = [new models.MailAddress(undefined, 'to@aspose.com')];
428+
emailDto.subject = 'Some subject';
429+
emailDto.body = 'Some body';
430+
emailDto.date = new Date();
431+
let mapi = await api.convertEmailModelToFile(new requests.ConvertEmailModelToFileRequest(
432+
'Msg', emailDto));
433+
let eml = await api.convertEmail(new requests.ConvertEmailRequest(
434+
'Eml', mapi.body));
435+
let emlString = eml.body.toString();
436+
expect(emlString).to.include(from);
437+
let dto = await api.getEmailFileAsModel(new requests.GetEmailFileAsModelRequest(eml.body));
438+
expect(dto.body.from.address).to.be.equal(from);
439+
});
440+
404441
async function createCalendar(startDate?: Date): Promise<string> {
405442
const fileName = uuidv4() + '.ics';
406443
startDate = (startDate == null) ? getDate(undefined, 1) : startDate;

0 commit comments

Comments
 (0)