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+ } ) ;
0 commit comments