Skip to content

Commit c647bc0

Browse files
committed
Added tests for MAPI calendar dto
1 parent 1489ba0 commit c647bc0

File tree

4 files changed

+75
-4
lines changed

4 files changed

+75
-4
lines changed

test/ai-test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ describe('AI tests', function () {
6363
});
6464

6565
it('Parse business card images to VCard contact files #aiBcr', async function () {
66-
const imageData = fs.readFileSync('test/td/test_single_0001.png');
66+
const imageData = fs.readFileSync('test/data/test_single_0001.png');
6767
const storageFileName = uuidv4() + '.png';
6868
// 1) Upload business card image to storage
6969
await td.api().uploadFile(
@@ -94,7 +94,7 @@ describe('AI tests', function () {
9494
});
9595

9696
it('Business card recognition without storage #aiBcr', async function () {
97-
const imageData = fs.readFileSync('test/td/test_single_0001.png').toString('base64');
97+
const imageData = fs.readFileSync('test/data/test_single_0001.png').toString('base64');
9898
const result = await td.api().aiBcrParse(new requests.AiBcrParseRequest(
9999
new models.AiBcrBase64Rq(undefined, [new models.AiBcrBase64Image(true, imageData)])));
100100
expect(result.body.value.length).to.be.equal(1);

test/calendar-test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ describe('Calendar tests', function() {
3232
let path = td.folder() + '/' + calendarFile;
3333
const downloaded = await td.api().downloadFile(new requests.DownloadFileRequest(path, td.storage()));
3434
const calendarRaw = downloaded.body.toString();
35-
expect(calendarRaw).to.contain('Organizer')
36-
calendarFile = uuidv4() + '.ics'
35+
expect(calendarRaw).to.contain('Organizer');
36+
calendarFile = uuidv4() + '.ics';
3737
path = td.folder() + '/' + calendarFile;
3838
await td.api().uploadFile(new requests.UploadFileRequest(path, downloaded.body, td.storage()));
3939
const exist = await td.api().objectExists(new requests.ObjectExistsRequest(path, td.storage()));

test/mapi-calendar-test.ts

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import * as requests from '../src/model/requests/requests';
2+
import * as models from '../src/model/model';
3+
import 'mocha';
4+
import {expect} from 'chai';
5+
import {suiteBase} from "./suite-base";
6+
import uuidv4 from "uuid/v4";
7+
8+
9+
describe('MAPI calendar tests', function() {
10+
let td = suiteBase(this);
11+
12+
it('Convert MAPI model to CalendarDto #pipeline', async () => {
13+
const mapiCalendarDto = getMapiCalendarDto();
14+
const calendarDto = await td.api().convertMapiCalendarModelToCalendarModel(
15+
new requests.ConvertMapiCalendarModelToCalendarModelRequest(mapiCalendarDto));
16+
expect(mapiCalendarDto.subject).to.be.eq(calendarDto.body.summary);
17+
expect(mapiCalendarDto.location).to.be.eq(calendarDto.body.location);
18+
});
19+
20+
it('Convert MAPI model to file #pipeline', async () => {
21+
const mapiCalendarDto = getMapiCalendarDto();
22+
const icsFile = await td.api().convertMapiCalendarModelToFile(
23+
new requests.ConvertMapiCalendarModelToFileRequest('Ics', mapiCalendarDto));
24+
const icsString = icsFile.body.toString();
25+
expect(icsString).to.contain(mapiCalendarDto.location);
26+
const mapiCalendarDtoConverted = await td.api().getCalendarFileAsMapiModel(
27+
new requests.GetCalendarFileAsMapiModelRequest(icsFile.body));
28+
expect(mapiCalendarDto.location).to.be.eq(mapiCalendarDtoConverted.body.location);
29+
});
30+
31+
it('Mapi calendar storage test #pipeline', async () => {
32+
const mapiCalendarDto = getMapiCalendarDto();
33+
const fileName = uuidv4() + '.msg';
34+
await td.api().saveMapiCalendarModel(
35+
new requests.SaveMapiCalendarModelRequest(fileName, "Msg",
36+
new models.StorageModelRqOfMapiCalendarDto(mapiCalendarDto, td.getStorageFolderLocation())));
37+
const mapiCalendarFromStorage = await td.api().getMapiCalendarModel(
38+
new requests.GetMapiCalendarModelRequest(fileName, td.folder(), td.storage()));
39+
expect(mapiCalendarDto.location).to.be.eq(mapiCalendarFromStorage.body.location);
40+
});
41+
42+
function getMapiCalendarDto(): models.MapiCalendarDto {
43+
const mapiCalendarDto = new models.MapiCalendarDto();
44+
const mapiRecipientDto = new models.MapiRecipientDto();
45+
mapiRecipientDto.addressType = "SMTP";
46+
mapiRecipientDto.displayName = "Attendee Name";
47+
mapiRecipientDto.emailAddress = "attendee@aspose.com";
48+
mapiRecipientDto.recipientType = "MapiTo";
49+
mapiCalendarDto.attendees = new models.MapiCalendarAttendeesDto([mapiRecipientDto]);
50+
mapiCalendarDto.clientIntent = ["Manager"];
51+
const recurrence = new models.MapiCalendarEventRecurrenceDto();
52+
const recurrencePatternDto = new models.MapiCalendarDailyRecurrencePatternDto();
53+
recurrencePatternDto.occurrenceCount = 10;
54+
recurrencePatternDto.weekStartDay = "Monday";
55+
recurrence.recurrencePattern = recurrencePatternDto;
56+
mapiCalendarDto.recurrence = recurrence;
57+
mapiCalendarDto.organizer = new models.MapiElectronicAddressDto(undefined, "organizer@aspose.com");
58+
mapiCalendarDto.busyStatus = "Tentative";
59+
mapiCalendarDto.startDate = td.getDate(undefined, 1);
60+
mapiCalendarDto.endDate = td.getDate(mapiCalendarDto.startDate, 1);
61+
mapiCalendarDto.location = "Some location";
62+
mapiCalendarDto.body = "Some description";
63+
mapiCalendarDto.bodyType = "PlainText";
64+
mapiCalendarDto.subject = "Some summary";
65+
return mapiCalendarDto;
66+
}
67+
});

test/suite-base.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ class SuiteBase {
5353
));
5454
return fileName;
5555
}
56+
57+
public getStorageFolderLocation(): models.StorageFolderLocation {
58+
return new models.StorageFolderLocation(this.storage(), this.folder());
59+
}
5660
}
5761

5862
export function suiteBase(suite: Suite): SuiteBase {

0 commit comments

Comments
 (0)