teams-network-records.test.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. import test from 'node:test';
  2. import assert from 'node:assert/strict';
  3. import { normalizeChats, normalizeMessages, normalizeCalendar } from '../src/teams-network-records.js';
  4. import { classifyMessage } from '../src/message-signals.js';
  5. // All data below is fictional; only the field names/types follow the supplied HAR.
  6. const chatId = '19:fictional-meeting@thread.v2';
  7. const options = { accountId: 'local-fictional-account', chatId, chatTitle: 'Fictional project' };
  8. const link = id => `https://teams.cloud.microsoft/api/chatsvc/apac/v1/users/ME/conversations/${encodeURIComponent(id)}`;
  9. function message(overrides = {}) {
  10. return { sequenceId: 1, conversationid: chatId, conversationLink: link(chatId),
  11. contenttype: 'text', type: 'Message', amsreferences: [], s2spartnername: 'fictional-partner',
  12. id: '1700000000123', clientmessageid: 'fictional-client-message', version: '1700000001123',
  13. messagetype: 'RichText/Html', content: '<p>Hello <b>fictional team</b> &amp; friends.</p><p>Next line.</p>',
  14. from: 'fictional-author-id', imdisplayname: 'Fictional author',
  15. composetime: '2023-11-14T22:13:20.000Z', originalarrivaltime: '2023-11-14T22:13:20.123Z',
  16. properties: { atp: 'fictional-unneeded-metadata' }, ...overrides };
  17. }
  18. test('normalizes observed message schema with caller identity, text, scoped ID, and allowlisted provenance', () => {
  19. const input = message({ accountId: 'wrong-account', authorization: 'secret-marker',
  20. fromDisplayNameInToken: 'token-derived-name', properties: { files: 'attachment-marker', authorization: 'nested-secret' } });
  21. const result = normalizeMessages({ messages: [input], tenantId: 'unneeded-tenant-id' }, options);
  22. assert.deepEqual(result, { records: [{
  23. source: 'web-api', accountId: options.accountId, kind: 'message',
  24. externalId: `${encodeURIComponent(chatId)}:1700000000123`, parentId: chatId,
  25. title: 'Fictional project', text: 'Hello fictional team & friends.\nNext line.',
  26. occurredAt: '2023-11-14T22:13:20.123Z', updatedAt: '2023-11-14T22:13:21.123Z',
  27. webUrl: null, deleted: false,
  28. raw: { messageId: '1700000000123', messageType: 'RichText/Html', author: 'Fictional author',
  29. senderId: null, mentions: null,
  30. composedAt: '2023-11-14T22:13:20.000Z', arrivedAt: '2023-11-14T22:13:20.123Z', version: '1700000001123' },
  31. }], pagination: {} });
  32. assert.doesNotMatch(JSON.stringify(result), /secret-marker|nested-secret|attachment-marker|token-derived-name|unneeded-tenant-id|fictional-author-id|fictional-client-message/);
  33. });
  34. test('encodes both identity components so equal message IDs in different chats do not collide', () => {
  35. const one = '19:fictional-a@thread.v2', two = '19:fictional-b@thread.v2';
  36. const build = id => normalizeMessages({ messages: [message({ id: 'id:/%:same', conversationid: id, conversationLink: link(id) })] }, { ...options, chatId: id }).records[0];
  37. assert.notEqual(build(one).externalId, build(two).externalId);
  38. assert.equal(build(one).externalId, `${encodeURIComponent(one)}:${encodeURIComponent('id:/%:same')}`);
  39. });
  40. test('retains only structured sender and mention evidence for downstream notifications', () => {
  41. const tenant = '33333333-3333-4333-8333-333333333333';
  42. const self = '11111111-1111-4111-8111-111111111111';
  43. const other = '22222222-2222-4222-8222-222222222222';
  44. const accountId = `web-api:${tenant}:${self}`;
  45. const input = message({ from: `https://teams.cloud.microsoft/api/chatsvc/apac/v1/users/ME/contacts/${encodeURIComponent(`8:orgid:${other}`)}`,
  46. properties: { mentions: JSON.stringify([{ '@type': 'mention', itemid: 0, mri: `8:orgid:${self}`, mentionType: 'person', displayName: 'unused-mention-name' }]),
  47. files: 'unneeded-attachment', authorization: 'nested-secret-marker' } });
  48. const record = normalizeMessages({ messages: [input] }, { ...options, accountId }).records[0];
  49. assert.equal(record.raw.senderId, other); assert.equal(record.raw.selfUserId, self);
  50. assert.deepEqual(record.raw.mentions, [{ id: self, type: 'user' }]);
  51. assert.equal(classifyMessage(record).mentionsSelf, true);
  52. assert.equal(classifyMessage(record).isFromSelf, false);
  53. assert.doesNotMatch(JSON.stringify(record.raw), /https:|unused-mention-name|unneeded-attachment|nested-secret-marker/);
  54. const missing = normalizeMessages({ messages: [message({ properties: {} })] }, { ...options, accountId }).records[0];
  55. const empty = normalizeMessages({ messages: [message({ properties: { mentions: '[]' } })] }, { ...options, accountId }).records[0];
  56. assert.equal(classifyMessage(missing).mentionsSelf, null);
  57. assert.equal(classifyMessage(empty).mentionsSelf, false);
  58. });
  59. test('rejects the entire mixed-chat response even if the mismatched item is a skipped control message', () => {
  60. const other = '19:fictional-other@thread.v2';
  61. for (const override of [
  62. { conversationid: other },
  63. { conversationLink: link(other) },
  64. { conversationid: other, conversationLink: link(other), messagetype: 'ThreadActivity/MemberJoined' },
  65. ]) {
  66. assert.throws(() => normalizeMessages({ messages: [message(), message({ id: 'other-message', ...override })] }, options), { code: 'conversation_mismatch' });
  67. }
  68. });
  69. test('requires observed conversation identity fields and rejects malformed or foreign links without logging them', () => {
  70. for (const override of [
  71. { conversationid: undefined }, { conversationLink: undefined },
  72. { conversationLink: 'https://untrusted.example/api/chatsvc/apac/v1/users/ME/conversations/secret-marker' },
  73. { conversationLink: `${link(chatId)}?token=secret-marker` },
  74. { conversationLink: `${link(chatId)}#secret-marker` },
  75. { conversationLink: 'https://teams.cloud.microsoft/other-route/secret-marker' },
  76. ]) {
  77. assert.throws(() => normalizeMessages({ messages: [message(override)] }, options), error => {
  78. assert.doesNotMatch(error.message, /secret-marker|https:\/\//); return true;
  79. });
  80. }
  81. });
  82. test('skips observed system/control/media types and never infers message deletion', () => {
  83. const types = ['Event/Call', 'ThreadActivity/AddCustomApp', 'ThreadActivity/TopicUpdate', 'ThreadActivity/MemberJoined', 'ThreadActivity/MemberLeft', 'RichText/Media_CallRecording', 'RichText/Media_CallTranscript'];
  84. const result = normalizeMessages({ messages: [
  85. ...types.map((type, index) => message({ id: `control-${index}`, messagetype: type, content: '<control>not a user message</control>', deleted: true })),
  86. message({ properties: { deletetime: '2023-11-14T22:13:20.000Z' }, deletedDateTime: '2023-11-14T22:13:20.000Z', '@removed': {} }),
  87. ] }, options);
  88. assert.equal(result.records.length, 1);
  89. assert.equal(result.records[0].deleted, false);
  90. assert.equal(normalizeMessages({ messages: [] }, options).records.length, 0);
  91. });
  92. test('extracts only the observed metadata fields without putting the continuation cursor in record data', () => {
  93. const syncState = `${link(chatId)}/messages?syncState=fictional-cursor`;
  94. const result = normalizeMessages({ messages: [message()], _metadata: {
  95. lastCompleteSegmentStartTime: 0, lastCompleteSegmentEndTime: 1700000000000, syncState,
  96. nextLink: 'not-observed', authorization: 'private-marker',
  97. } }, options);
  98. assert.deepEqual(result.pagination, { lastCompleteSegmentStartTime: 0, lastCompleteSegmentEndTime: 1700000000000, syncState });
  99. assert.doesNotMatch(JSON.stringify(result.records), /fictional-cursor|private-marker/);
  100. assert.equal(Object.hasOwn(result.pagination, 'nextLink'), false);
  101. assert.throws(() => normalizeMessages({ messages: [], _metadata: { lastCompleteSegmentStartTime: -1 } }, options), { code: 'invalid_metadata' });
  102. });
  103. test('dates are valid normalized ISO timestamps and invalid or timezone-free dates remain unknown', () => {
  104. const first = normalizeMessages({ messages: [message({ originalarrivaltime: '2026-09-08T10:30:00.1234567+08:00' })] }, options).records[0];
  105. assert.equal(first.occurredAt, '2026-09-08T02:30:00.123Z');
  106. for (const originalarrivaltime of ['2026-02-30T12:00:00Z', '2026-09-08T12:00:00', '2026-13-01T12:00:00Z', '2026-09-08T24:00:00Z', 'not a date']) {
  107. const result = normalizeMessages({ messages: [message({ originalarrivaltime, composetime: 'invalid', version: 'invalid' })] }, options).records[0];
  108. assert.equal(result.occurredAt, null); assert.equal(result.updatedAt, null);
  109. assert.equal(Object.hasOwn(result.raw, 'arrivedAt'), false);
  110. }
  111. });
  112. test('HTML is converted to plain text and empty user messages are skipped', () => {
  113. const result = normalizeMessages({ messages: [
  114. message({ content: '<script>secret()</script><style>.x{}</style><p>&lt;safe&gt; &#x1F600;<br>second</p>', imdisplayname: '<b>Fictional author</b>' }),
  115. message({ id: 'empty', content: '<p><br></p>' }),
  116. ] }, { ...options, chatTitle: '' });
  117. assert.equal(result.records.length, 1);
  118. assert.equal(result.records[0].text, '<safe> 😀\nsecond');
  119. assert.equal(result.records[0].title, '聊天消息');
  120. assert.equal(result.records[0].raw.author, 'Fictional author');
  121. });
  122. test('image-backed inline and emoji-only messages are retained in order without treating reactions as body text', () => {
  123. const result = normalizeMessages({ messages: [
  124. message({ id: 'inline-emoji', content: '<p>收到<span class="emoticon" title="smile"><img itemtype="http://schema.skype.com/Emoji" alt="😀" title="smile" src="https://example.invalid/private-emoji"></span>了<img alt="👍🏽"></p>', properties: { emotions: [{ key: 'reaction-marker', users: ['private-reactor'] }] } }),
  125. message({ id: 'only-emoji', content: '<p><img alt="&#x1F469;&#x1F3FD;&zwj;&#x1F4BB;"><img alt="(laugh)"></p>' }),
  126. message({ id: 'only-image', content: '<img src="https://example.invalid/private-image">' }),
  127. message({ id: 'reactions-only', content: '', properties: { emotions: [{ key: 'reaction-marker', users: ['private-reactor'] }] } }),
  128. ] }, options);
  129. assert.equal(result.records.length, 3);
  130. assert.deepEqual(result.records.map(record => record.text), ['收到😀了👍🏽', '👩🏽‍💻(laugh)', '[图片]']);
  131. assert.doesNotMatch(JSON.stringify(result.records), /private-emoji|private-image|reaction-marker|private-reactor/);
  132. });
  133. test('observed ordinary Text retains literal text while 48 activity notifications stay out of chat records', () => {
  134. const result = normalizeMessages({ messages: [message({ messagetype: 'Text', content: '<literal> &amp; text' })] }, options);
  135. assert.equal(result.records.length, 1); assert.equal(result.records[0].text, '<literal> &amp; text');
  136. const activity = '48:fictional-notifications';
  137. const skipped = normalizeMessages({ messages: [message({ messagetype: 'Text', content: 'notification', conversationid: activity, conversationLink: link(activity), properties: { activity: '{}' } })] }, { ...options, chatId: activity });
  138. assert.equal(skipped.records.length, 0);
  139. });
  140. test('accepts the observed empty incremental chat response', () => {
  141. assert.deepEqual(normalizeChats({ chats: [], teams: [], users: [], metadata: { syncToken: 'fictional-cursor', forwardSyncToken: null, isPartialData: false, hasMoreChats: false } }, options), { records: [], chats: [] });
  142. });
  143. test('normalizes the newly observed nonempty chat schema while ignoring previews, credentials, and deletion flags', () => {
  144. const result = normalizeChats({ chats: [{ id: chatId, title: 'Fictional meeting',
  145. threadType: 'meeting', isOneOnOne: false, createdAt: '2023-11-14T22:13:20Z', version: 1700000001123,
  146. members: [{ friendlyName: 'Fictional member', mri: 'private-member-marker' }],
  147. lastMessage: { content: 'private-preview-marker', containerId: 'another-chat' },
  148. tenantId: 'private-tenant-marker', isConversationDeleted: true, hidden: true,
  149. authorization: 'private-secret-marker', meetingInformation: { meetingJoinUrl: 'https://example.invalid/private-marker' },
  150. }] }, options);
  151. assert.deepEqual(result.chats, [{ id: chatId, title: 'Fictional meeting' }]);
  152. assert.deepEqual(result.records, [{ source: 'web-api', accountId: options.accountId, kind: 'chat', externalId: chatId,
  153. title: 'Fictional meeting', text: '', occurredAt: '2023-11-14T22:13:20.000Z', updatedAt: '2023-11-14T22:13:21.123Z', webUrl: null, deleted: false,
  154. raw: { chatId, titleSource: 'explicit', members: [], membersComplete: false, threadType: 'meeting', isOneOnOne: false, createdAt: '2023-11-14T22:13:20.000Z', version: 1700000001123 },
  155. }]);
  156. assert.doesNotMatch(JSON.stringify(result), /private-|another-chat/);
  157. const untitled = normalizeChats({ chats: [{ id: '19:fictional-direct', title: '', isOneOnOne: true, members: [{ friendlyName: 'Fictional person' }] }] }, options);
  158. assert.equal(untitled.chats[0].title, '聊天');
  159. });
  160. test('rejects missing identities and unrelated response shapes instead of silently treating them as empty results', () => {
  161. for (const payload of [null, [], {}, { value: [] }, { messages: {} }]) assert.throws(() => normalizeMessages(payload, options), { code: 'invalid_message_payload' });
  162. assert.throws(() => normalizeMessages({ messages: [] }, { ...options, accountId: '' }), { code: 'invalid_identity' });
  163. assert.throws(() => normalizeMessages({ messages: [message({ id: '' })] }, options), { code: 'invalid_identity' });
  164. assert.throws(() => normalizeChats({ value: [] }, options), { code: 'invalid_chat_payload' });
  165. });
  166. test('chat normalization names only the verified other member and records explicit-title provenance', () => {
  167. const tenant='11111111-1111-1111-1111-111111111111', self='22222222-2222-2222-2222-222222222222', peer='33333333-3333-3333-3333-333333333333';
  168. const accountId=`web-api:${tenant}:${self}`;
  169. const input={id:chatId,title:'',isOneOnOne:true,members:[
  170. {objectId:self,mri:`8:orgid:${self}`,friendlyName:'Fictional self'},
  171. {objectId:peer,mri:`8:orgid:${peer}`,friendlyName:'Fictional peer'},
  172. ]};
  173. const named=normalizeChats({chats:[input]}, {accountId}).records[0];
  174. assert.equal(named.title,'Fictional peer');assert.equal(named.raw.titleSource,'members');assert.equal(named.raw.peerId,peer);
  175. assert.equal(named.raw.membersComplete,true);
  176. const explicit=normalizeChats({chats:[{...input,title:'聊天'}]}, {accountId}).records[0];
  177. assert.equal(explicit.title,'聊天');assert.equal(explicit.raw.titleSource,'explicit');
  178. const unnamed=normalizeChats({chats:[{...input,members:input.members.map(({friendlyName,...member})=>member)}]}, {accountId}).records[0];
  179. assert.equal(unnamed.title,'聊天');assert.equal(unnamed.raw.titleSource,'placeholder');assert.equal(unnamed.raw.members.length,2);
  180. });
  181. function restEvent(overrides = {}) {
  182. return { id: 'fictional-calendar-event/+A', subject: 'Fictional planning meeting',
  183. body: { contentType: 'html', content: '<p>Discuss the <b>fictional</b> plan.</p>' },
  184. start: { dateTime: '2026-09-08T01:00:00.0000000', timeZone: 'UTC' },
  185. end: { dateTime: '2026-09-08T02:00:00.0000000', timeZone: 'UTC' },
  186. createdDateTime: '2026-09-01T09:00:00Z', lastModifiedDateTime: '2026-09-07T09:00:00Z',
  187. isCancelled: false, isAllDay: false, ...overrides };
  188. }
  189. test('normalizes observed REST calendar details with explicit UTC and narrowly retained provenance', () => {
  190. const { records, coverage } = normalizeCalendar({ value: [restEvent({
  191. attendees: [{ emailAddress: { address: 'private-email-marker' } }],
  192. recurrence: { range: { private: 'private-recurrence-marker' } },
  193. onlineMeeting: { joinUrl: 'https://example.invalid/private-join-marker' },
  194. authorization: 'private-token-marker',
  195. })] }, options);
  196. assert.deepEqual(coverage, { received: 1, recorded: 1, skippedIncomplete: 0, unresolvedTimezones: 0, schema: 'rest-events' });
  197. assert.equal(records[0].source, 'web-api'); assert.equal(records[0].accountId, options.accountId);
  198. assert.equal(records[0].externalId, `rest-events:${encodeURIComponent('fictional-calendar-event/+A')}`);
  199. assert.equal(records[0].text, 'Discuss the fictional plan.');
  200. assert.equal(records[0].occurredAt, '2026-09-08T01:00:00.000Z');
  201. assert.equal(records[0].raw.detailLevel, 'detail');
  202. assert.doesNotMatch(JSON.stringify(records), /private-email-marker|private-recurrence-marker|private-join-marker|private-token-marker/);
  203. });
  204. test('titled calendar views omit unknown body text for caller-side merging with previous details', () => {
  205. const complete = normalizeCalendar({ value: [restEvent()] }, options).records[0];
  206. const summary = normalizeCalendar({ value: [restEvent({ body: undefined })] }, options).records[0];
  207. assert.equal(summary.externalId, complete.externalId);
  208. assert.equal(summary.title, complete.title);
  209. assert.equal(summary.text, undefined);
  210. assert.equal(summary.raw.detailLevel, 'summary');
  211. assert.equal(normalizeCalendar({ value: [restEvent({ body: { contentType: 'text', content: '' } })] }, options).records[0].raw.detailLevel, 'detail');
  212. });
  213. test('calendar lookups with only id and times are skipped rather than overwriting titled events', () => {
  214. const result = normalizeCalendar({ value: [restEvent({ subject: undefined, body: undefined })] }, options);
  215. assert.equal(result.records.length, 0);
  216. assert.equal(result.coverage.skippedIncomplete, 1);
  217. });
  218. test('calendar wall-clock times with unknown timezones are retained without inventing an instant', () => {
  219. for (const timeZone of ['', 'Pacific Standard Time', 'Asia/Singapore']) {
  220. const result = normalizeCalendar({ value: [restEvent({ start: { dateTime: '2026-09-08T09:00:00', timeZone } })] }, options);
  221. assert.equal(result.records[0].occurredAt, null);
  222. assert.equal(result.records[0].raw.start.dateTime, '2026-09-08T09:00:00');
  223. assert.equal(result.coverage.unresolvedTimezones, 1);
  224. }
  225. const offset = normalizeCalendar({ value: [restEvent({ start: { dateTime: '2026-09-08T09:00:00+08:00', timeZone: 'Asia/Singapore' } })] }, options);
  226. assert.equal(offset.records[0].occurredAt, '2026-09-08T01:00:00.000Z');
  227. });
  228. test('cancelled calendar events retain actual cancellation without becoming deletion tombstones', () => {
  229. const result = normalizeCalendar({ value: [restEvent({ isCancelled: true, '@removed': {}, deletedDateTime: '2026-09-08T01:00:00Z' })] }, options);
  230. assert.equal(result.records[0].deleted, false);
  231. assert.equal(result.records[0].raw.isCancelled, true);
  232. assert.equal(result.records[0].text, 'Discuss the fictional plan.');
  233. assert.throws(() => normalizeCalendar({ Header: {}, Body: { TimeZones: [] } }, options), { code: 'invalid_calendar_payload' });
  234. });
  235. function owaEvent(overrides = {}) {
  236. return { __type: 'CalendarItem:#Exchange', ItemId: { __type: 'ItemId:#Exchange', ChangeKey: 'fictional-change-key', Id: 'fictional-calendar-event/+A' },
  237. ParentFolderId: { Id: 'fictional-calendar-folder', ChangeKey: 'fictional-folder-change-key' },
  238. UID: 'fictional-event-uid', Subject: 'Fictional OWA meeting',
  239. Start: '2026-09-08T09:00:00+08:00', End: '2026-09-08T10:00:00+08:00',
  240. StartTimeZoneId: 'Singapore Standard Time', EndTimeZoneId: 'Singapore Standard Time',
  241. IsCancelled: false, IsAllDayEvent: false, Preview: 'short private-preview-marker',
  242. CalendarItemType: 'Single', IsRecurring: false,
  243. Organizer: { Mailbox: { Name: 'Fictional organizer', EmailAddress: 'private-organizer-marker' } },
  244. Location: { DisplayName: 'Fictional location' }, ...overrides };
  245. }
  246. test('normalizes observed OWA CalendarView and StartupData summaries without treating Preview as full body', () => {
  247. const view = { Body: { ResponseCode: 'NoError', ResponseClass: 'Success', Items: [owaEvent()] } };
  248. for (const payload of [view, { getCalendarView: view }]) {
  249. const { records, coverage } = normalizeCalendar(payload, options);
  250. assert.equal(coverage.schema, 'owa-calendar'); assert.equal(coverage.recorded, 1);
  251. assert.equal(records[0].externalId, `owa-calendar:${encodeURIComponent('fictional-calendar-event/+A')}`);
  252. assert.equal(records[0].title, 'Fictional OWA meeting'); assert.equal(records[0].text, undefined);
  253. assert.equal(records[0].occurredAt, '2026-09-08T01:00:00.000Z');
  254. assert.equal(records[0].raw.detailLevel, 'summary');
  255. assert.doesNotMatch(JSON.stringify(records), /private-preview-marker|private-organizer-marker|fictional-calendar-folder|fictional-change-key/);
  256. }
  257. });
  258. test('OWA detail responses use the same native event ID as views and remain distinct from REST IDs', () => {
  259. const item = owaEvent({ Body: { BodyType: 'HTML', Value: '<p>Full <b>fictional</b> description.</p>' },
  260. DateTimeCreated: '2026-09-01T09:00:00Z', LastModifiedTime: '2026-09-07T09:00:00Z',
  261. RequiredAttendees: [{ Mailbox: { EmailAddress: 'private-attendee-marker' } }], OnlineMeetingJoinUrl: 'https://example.invalid/private-link-marker',
  262. });
  263. const result = normalizeCalendar({ Body: { ResponseMessages: { Items: [
  264. { ResponseCode: 'NoError', ResponseClass: 'Success', Items: [item] },
  265. ] } } }, options);
  266. const detail = result.records[0];
  267. const summary = normalizeCalendar({ Body: { Items: [owaEvent()] } }, options).records[0];
  268. const rest = normalizeCalendar({ value: [restEvent()] }, options).records[0];
  269. assert.equal(detail.externalId, summary.externalId);
  270. assert.notEqual(detail.externalId, rest.externalId);
  271. assert.equal(detail.text, 'Full fictional description.');
  272. assert.equal(detail.raw.detailLevel, 'detail');
  273. assert.equal(detail.updatedAt, '2026-09-07T09:00:00.000Z');
  274. assert.doesNotMatch(JSON.stringify(result), /private-attendee-marker|private-link-marker/);
  275. });
  276. test('OWA cancellation remains an explicit observation and response failures cannot masquerade as an empty calendar', () => {
  277. const cancelled = normalizeCalendar({ Body: { Items: [owaEvent({ IsCancelled: true })] } }, options).records[0];
  278. assert.equal(cancelled.deleted, false); assert.equal(cancelled.raw.isCancelled, true);
  279. for (const payload of [
  280. { Body: { ResponseClass: 'Error', ResponseCode: 'ErrorAccessDenied', Items: [] } },
  281. { Body: { ResponseMessages: { Items: [{ ResponseCode: 'ErrorItemNotFound', ResponseClass: 'Error' }] } } },
  282. ]) assert.throws(() => normalizeCalendar(payload, options), { code: 'calendar_response_error' });
  283. });