calendar-link
Version:
📅 Calendar link generator for popular services, like Google, Outlook, and Yahoo.
113 lines • 3.98 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const index_1 = require("./index");
describe("all-day events", () => {
test("ics date-only events are timezone-stable", () => {
const link = (0, index_1.ics)({ title: "Dec 29", start: "2025-12-29", allDay: true });
expect(decodeURIComponent(link)).toContain("DTSTART:20251229");
expect(decodeURIComponent(link)).toContain("DTEND:20251230");
});
});
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();
jest.setSystemTime(new Date("2019-12-28T12:00:00.000Z"));
jest.spyOn(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