Skip to content

Commit ecb137e

Browse files
committed
Added calendar converter test
1 parent a9ec6f1 commit ecb137e

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

src/api.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,6 +1274,7 @@ export class EmailApi {
12741274
qs: queryParameters,
12751275
headers: headerParams,
12761276
uri: localVarPath,
1277+
json: true,
12771278
encoding: null,
12781279
};
12791280

@@ -1359,6 +1360,7 @@ export class EmailApi {
13591360
qs: queryParameters,
13601361
headers: headerParams,
13611362
uri: localVarPath,
1363+
json: true,
13621364
encoding: null,
13631365
body: ObjectSerializer.serialize(requestObj.calendarDto, "CalendarDto"),
13641366
};
@@ -1421,6 +1423,7 @@ export class EmailApi {
14211423
qs: queryParameters,
14221424
headers: headerParams,
14231425
uri: localVarPath,
1426+
json: true,
14241427
encoding: null,
14251428
};
14261429

@@ -1466,6 +1469,7 @@ export class EmailApi {
14661469
qs: queryParameters,
14671470
headers: headerParams,
14681471
uri: localVarPath,
1472+
json: true,
14691473
encoding: null,
14701474
body: ObjectSerializer.serialize(requestObj.contactDto, "ContactDto"),
14711475
};
@@ -1522,6 +1526,7 @@ export class EmailApi {
15221526
qs: queryParameters,
15231527
headers: headerParams,
15241528
uri: localVarPath,
1529+
json: true,
15251530
encoding: null,
15261531
};
15271532

@@ -1567,6 +1572,7 @@ export class EmailApi {
15671572
qs: queryParameters,
15681573
headers: headerParams,
15691574
uri: localVarPath,
1575+
json: true,
15701576
encoding: null,
15711577
body: ObjectSerializer.serialize(requestObj.emailDto, "EmailDto"),
15721578
};
@@ -2561,6 +2567,7 @@ export class EmailApi {
25612567
qs: queryParameters,
25622568
headers: headerParams,
25632569
uri: localVarPath,
2570+
json: true,
25642571
encoding: null,
25652572
};
25662573

@@ -2864,6 +2871,7 @@ export class EmailApi {
28642871
qs: queryParameters,
28652872
headers: headerParams,
28662873
uri: localVarPath,
2874+
json: true,
28672875
encoding: null,
28682876
};
28692877

@@ -2918,6 +2926,7 @@ export class EmailApi {
29182926
qs: queryParameters,
29192927
headers: headerParams,
29202928
uri: localVarPath,
2929+
json: true,
29212930
encoding: null,
29222931
};
29232932

@@ -3253,6 +3262,7 @@ export class EmailApi {
32533262
qs: queryParameters,
32543263
headers: headerParams,
32553264
uri: localVarPath,
3265+
json: true,
32563266
encoding: null,
32573267
};
32583268

@@ -3313,6 +3323,7 @@ export class EmailApi {
33133323
qs: queryParameters,
33143324
headers: headerParams,
33153325
uri: localVarPath,
3326+
json: true,
33163327
encoding: null,
33173328
};
33183329

@@ -3728,6 +3739,7 @@ export class EmailApi {
37283739
qs: queryParameters,
37293740
headers: headerParams,
37303741
uri: localVarPath,
3742+
json: true,
37313743
encoding: null,
37323744
};
37333745

@@ -3782,6 +3794,7 @@ export class EmailApi {
37823794
qs: queryParameters,
37833795
headers: headerParams,
37843796
uri: localVarPath,
3797+
json: true,
37853798
encoding: null,
37863799
};
37873800

@@ -4265,6 +4278,7 @@ export class EmailApi {
42654278
qs: queryParameters,
42664279
headers: headerParams,
42674280
uri: localVarPath,
4281+
json: true,
42684282
encoding: null,
42694283
};
42704284

test/api-test.ts

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ describe('EmailApi', function () {
8989
startDate.setMilliseconds(0);
9090
const calendarFile = await createCalendar(startDate);
9191
const calendar = await api.getCalendar(new requests.GetCalendarRequest(calendarFile, folder, storage));
92-
const startDateProperty = calendar.body.internalProperties.find(item => item.name == 'STARTDATE') as models.PrimitiveObject;
92+
const startDateProperty = calendar.body.internalProperties.find(
93+
item => item.name == 'STARTDATE') as models.PrimitiveObject;
9394
const factStartDate = new Date(startDateProperty.value);
9495
expect(factStartDate.getTime()).to.equal(startDate.getTime());
9596
});
@@ -277,7 +278,8 @@ describe('EmailApi', function () {
277278
new models.PrimitiveObject("Tag:'PidTagBody':0x1000:String"),
278279
new models.PrimitiveObject("Tag:'PidTagStoreSupportMask':0x340D:Integer32", undefined, "265849"),
279280
new models.PrimitiveObject("Tag:'PidTagSurname':0x3A11:String", undefined, "Surname"),
280-
new models.PrimitiveObject("Tag:'PidTagOtherTelephoneNumber':0x3A1F:String", undefined, "+79123456789"),
281+
new models.PrimitiveObject("Tag:'PidTagOtherTelephoneNumber':0x3A1F:String", undefined,
282+
"+79123456789"),
281283
new models.PrimitiveObject("Tag:'':0x6662:Integer32", undefined, "0"),
282284
new models.PrimitiveObject(
283285
"Lid:'PidLidAddressBookProviderArrayType':0x8029:Integer32:00062004-0000-0000-c000-000000000046",
@@ -372,6 +374,33 @@ describe('EmailApi', function () {
372374
.to.be.equal(multiAccount.sendAccount.credentials.discriminator);
373375
});
374376

377+
it('Check calendar converter #pipeline', async function () {
378+
const location = 'Some location';
379+
//Create DTO with specified location:
380+
let calendarDto = new models.CalendarDto();
381+
calendarDto.location = 'Some location';
382+
calendarDto.summary = 'Some summary';
383+
calendarDto.description = 'some description';
384+
calendarDto.startDate = getDate(undefined, 1);
385+
calendarDto.endDate = getDate(calendarDto.startDate, 1);
386+
calendarDto.organizer = new models.MailAddress('undefined', 'organizer@aspose.com');
387+
calendarDto.attendees = [new models.MailAddress('undefined', "attendee@aspose.com")];
388+
//We can convert this DTO to a MAPI or ICS file:
389+
let mapi = await api.convertCalendarModelToFile(new requests.ConvertCalendarModelToFileRequest(
390+
'Msg', calendarDto));
391+
//File content is available at mapi.body as a Buffer object
392+
//Let's convert this buffer to an ICS file:
393+
let ics = await api.convertCalendar(new requests.ConvertCalendarRequest(
394+
'Ics', mapi.body));
395+
//ICS is a text format. We can convert the buffer to a string and check that it
396+
//contains specified location as a substring:
397+
let icsString = ics.body.toString();
398+
expect(icsString).to.include(location);
399+
//We can also convert a file buffer back to a CalendarDto
400+
let dto = await api.getCalendarFileAsModel(new requests.GetCalendarFileAsModelRequest(ics.body));
401+
expect(dto.body.location).to.be.equal(location);
402+
});
403+
375404
async function createCalendar(startDate?: Date): Promise<string> {
376405
const fileName = uuidv4() + '.ics';
377406
startDate = (startDate == null) ? getDate(undefined, 1) : startDate;

0 commit comments

Comments
 (0)