UNPKG

calendar-link

Version:

📅 Calendar link generator for popular services, like Google, Outlook, and Yahoo.

106 lines • 3.65 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const index_1 = require("./index"); for (const service of [ index_1.aol, index_1.google, index_1.ics, index_1.msTeams, index_1.office365, index_1.office365Mobile, index_1.outlook, index_1.outlookMobile, index_1.yahoo, ]) { beforeAll(() => { jest.useFakeTimers("modern"); jest.setSystemTime(new Date("2019-12-28T12:00:00.000Z")); jest.spyOn(global.Math, "random").mockReturnValue(0.12345); }); afterAll(() => { jest.useRealTimers(); }); describe(`${service.name} service`, () => { test(`generate a ${service.name} link`, () => { const event = { title: "Birthday party", start: "2019-12-29", duration: [2, "hour"], }; const link = service(event); expect(link).toMatchSnapshot(); }); test(`generate a ${service.name} link with description`, () => { const event = { title: "Birthday party", start: "2019-12-29", duration: [2, "hour"], description: "Bring gifts!", }; const link = service(event); expect(link).toMatchSnapshot(); }); test(`generate a ${service.name} link with time & timezone`, () => { const event = { title: "Birthday party", start: "2019-12-29T12:00:00.000+01:00", duration: [2, "hour"], }; const link = service(event); expect(link).toMatchSnapshot(); }); test(`generate an all day ${service.name} link`, () => { const event = { title: "Birthday party", start: "2019-12-29", allDay: true, status: "CONFIRMED", }; const link = service(event); expect(link).toMatchSnapshot(); }); test(`generate a multi day ${service.name} link`, () => { const event = { title: "Birthday party", start: "2019-12-29", end: "2020-01-12", allDay: true, }; const link = service(event); expect(link).toMatchSnapshot(); }); test(`generate a recurring ${service.name} link`, () => { const event = { title: "Birthday party", start: "2019-12-29", duration: [2, "hour"], rRule: "FREQ=YEARLY;INTERVAL=1", }; const link = service(event); expect(link).toMatchSnapshot(); }); test(`generate a ${service.name} link with guests`, () => { const event = { title: "Birthday party", start: "2019-12-29", duration: [2, "hour"], guests: ["hello@example.com", "another@example.com"], }; const link = service(event); expect(link).toMatchSnapshot(); }); if (service.name === index_1.ics.name) { test(`generate a ${service.name} link with uid`, () => { const event = { title: "Birthday party", start: "2019-12-29", duration: [2, "hour"], uid: 'abc_123' }; const link = service(event); expect(link).toMatchSnapshot(); }); } }); } //# sourceMappingURL=index.spec.js.map