2023-06-19 14:10:06 +00:00
|
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
|
|
|
|
import { getCalendarCredentials } from "./CalendarManager";
|
|
|
|
|
|
|
|
describe("CalendarManager tests", () => {
|
|
|
|
describe("fn: getCalendarCredentials", () => {
|
|
|
|
it("should only return credentials for calendar apps", () => {
|
|
|
|
const googleCalendarCredentials = {
|
|
|
|
id: "1",
|
|
|
|
appId: "google-calendar",
|
|
|
|
type: "google_calendar",
|
|
|
|
userId: "3",
|
|
|
|
key: {
|
2023-10-03 18:52:19 +00:00
|
|
|
access_token: "google_calendar_key",
|
2023-06-19 14:10:06 +00:00
|
|
|
},
|
2023-10-03 18:52:19 +00:00
|
|
|
invalid: false,
|
2023-06-19 14:10:06 +00:00
|
|
|
};
|
|
|
|
|
2023-10-03 18:52:19 +00:00
|
|
|
const credentials = [
|
|
|
|
googleCalendarCredentials,
|
|
|
|
{
|
|
|
|
id: "2",
|
|
|
|
appId: "office365-video",
|
|
|
|
type: "office365_video",
|
|
|
|
userId: "4",
|
|
|
|
key: {
|
|
|
|
access_token: "office365_video_key",
|
|
|
|
},
|
|
|
|
invalid: false,
|
2023-06-19 14:10:06 +00:00
|
|
|
},
|
2023-10-03 18:52:19 +00:00
|
|
|
];
|
2023-06-19 14:10:06 +00:00
|
|
|
|
|
|
|
const calendarCredentials = getCalendarCredentials(credentials);
|
|
|
|
expect(calendarCredentials).toHaveLength(1);
|
|
|
|
expect(calendarCredentials[0].credential).toBe(googleCalendarCredentials);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|