78 行
3.6 KiB
TypeScript
78 行
3.6 KiB
TypeScript
import {
|
|
CardCalendarService,
|
|
generateGoogleCalendarUrl,
|
|
generateOutlookCalendarUrl,
|
|
generateOffice365CalendarUrl,
|
|
MeetingEventOptions,
|
|
} from '../../src/modules/card/service/calendar';
|
|
|
|
describe('Point 42: 出海潜客跨国会议 Google Calendar / Outlook 一键预约同步', () => {
|
|
let calendarService: CardCalendarService;
|
|
|
|
const mockMeeting: MeetingEventOptions = {
|
|
summary: 'OmniCard Global Expansion Demo (Dubai GITEX)',
|
|
description: 'Discussing AI Business Cards & Regional CRM Deployment for Middle East.\nMeeting Link: https://meet.google.com/xyz-abc-def',
|
|
location: 'Dubai World Trade Centre, Hall 4 & Google Meet',
|
|
startTime: new Date(Date.UTC(2026, 9, 15, 10, 0, 0)),
|
|
endTime: new Date(Date.UTC(2026, 9, 15, 11, 0, 0)),
|
|
};
|
|
|
|
beforeEach(() => {
|
|
calendarService = new CardCalendarService();
|
|
});
|
|
|
|
describe('1. Google Calendar Web 预约链接生成 (generateGoogleCalendarUrl)', () => {
|
|
it('应生成符合 Google Calendar 规范的模板 URL', () => {
|
|
const url = generateGoogleCalendarUrl(mockMeeting);
|
|
expect(url).toContain('calendar.google.com/calendar/render?action=TEMPLATE');
|
|
expect(decodeURIComponent(url.replace(/\+/g, ' '))).toContain('text=OmniCard Global Expansion Demo (Dubai GITEX)');
|
|
expect(url).toContain('dates=20261015T100000Z%2F20261015T110000Z');
|
|
expect(decodeURIComponent(url.replace(/\+/g, ' '))).toContain('location=Dubai World Trade Centre');
|
|
expect(url).toContain('details=');
|
|
});
|
|
|
|
it('支持包含组织者与参会人 email 添加至 details 备注中', () => {
|
|
const meetingWithEmails: MeetingEventOptions = {
|
|
...mockMeeting,
|
|
organizer: { name: 'Sarah Lynn', email: 'sarah@omnicard.ai' },
|
|
attendees: [{ name: 'Ahmed', email: 'ahmed@emirates.ae' }],
|
|
};
|
|
const url = generateGoogleCalendarUrl(meetingWithEmails);
|
|
expect(decodeURIComponent(url)).toContain('sarah@omnicard.ai');
|
|
expect(decodeURIComponent(url)).toContain('ahmed@emirates.ae');
|
|
});
|
|
});
|
|
|
|
describe('2. Outlook / Office 365 预约链接生成', () => {
|
|
it('应生成 Outlook Live 深度一键日程链接', () => {
|
|
const url = generateOutlookCalendarUrl(mockMeeting);
|
|
expect(url).toContain('outlook.live.com/calendar/0/deeplink/compose');
|
|
expect(url).toContain('rru=addevent');
|
|
expect(decodeURIComponent(url.replace(/\+/g, ' '))).toContain('subject=OmniCard Global Expansion Demo (Dubai GITEX)');
|
|
expect(url).toContain('startdt=2026-10-15T10%3A00%3A00.000Z');
|
|
expect(url).toContain('enddt=2026-10-15T11%3A00%3A00.000Z');
|
|
});
|
|
|
|
it('应生成 Office 365 商业版企业日历链接', () => {
|
|
const url = generateOffice365CalendarUrl(mockMeeting);
|
|
expect(url).toContain('outlook.office.com/calendar/0/deeplink/compose');
|
|
expect(url).toContain('rru=addevent');
|
|
expect(url).toContain('subject=');
|
|
});
|
|
});
|
|
|
|
describe('3. CardCalendarService 综合生成日历集合包 (generateCalendarInviteLinks)', () => {
|
|
it('应统一返回 Google、Outlook、Office365 链接与标准 RFC 5545 ICS 字符串', () => {
|
|
const invite = calendarService.generateCalendarInviteLinks(mockMeeting);
|
|
|
|
expect(invite.googleUrl).toBeDefined();
|
|
expect(invite.outlookUrl).toBeDefined();
|
|
expect(invite.office365Url).toBeDefined();
|
|
expect(invite.icsContent).toContain('BEGIN:VCALENDAR');
|
|
expect(invite.icsContent).toContain('BEGIN:VEVENT');
|
|
expect(invite.icsContent).toContain('SUMMARY:OmniCard Global Expansion Demo');
|
|
expect(invite.icsContent).toContain('END:VCALENDAR');
|
|
});
|
|
});
|
|
});
|