Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
QuantumManiac committed Jan 11, 2024
1 parent 002cb11 commit 8cb94ea
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 29 deletions.
2 changes: 1 addition & 1 deletion tests/unit/classes/CalendarEvent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe("classes/CalendarEvent", () => {
url: googleCalendarEvent.htmlLink,
description: "This is a description\nYep it is.",
minervaEventMetadata: {
channels: [slackChannels[0]],
channel: slackChannels[0],
meetingLink: "https://example.com",
},
location: googleCalendarEvent.location,
Expand Down
18 changes: 3 additions & 15 deletions tests/unit/utils/calendarDescription.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
parseDescription,
} from "../../../src/utils/calendarDescription";

import { slackChannels, defaultSlackChannels } from "../../fixtures/slackChannels";
import { slackChannels } from "../../fixtures/slackChannels";

describe("utils/calendarDescription", () => {
describe("splitDescription", () => {
Expand Down Expand Up @@ -135,7 +135,7 @@ describe("utils/calendarDescription", () => {
expect(result).toEqual({
description: "This is a description\nYep it is.",
minervaEventMetadata: {
channels: [slackChannels[0]],
channel: slackChannels[0],
meetingLink: "https://example.com",
},
});
Expand All @@ -153,19 +153,7 @@ describe("utils/calendarDescription", () => {
expect(result).toEqual({
description: "This is a description\nYep it is.",
minervaEventMetadata: {
channels: [slackChannels[0]],
},
});
});

it("should return the default channels when the channel specified is `default`", () => {
const description = `#default<br>This is a description<br>Yep it is.`;
const result = parseDescription(description, slackChannels);
result.minervaEventMetadata?.channels.sort((a, b) => a.name.localeCompare(b.name));
expect(result).toEqual({
description: "This is a description\nYep it is.",
minervaEventMetadata: {
channels: defaultSlackChannels,
channel: slackChannels[0],
},
});
});
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/utils/googleCalendar.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { parseEvents, parseEventsOfChannels } from "../../../src/utils/googleCalendar";
import { parseEvents, filterEventsForChannels } from "../../../src/utils/googleCalendar";
import { slackChannels } from "../../fixtures/slackChannels";
import CalendarEvent from "../../../src/classes/CalendarEvent";
import googleCalendarEvent from "../../fixtures/googleCalendarEvent.json";
Expand All @@ -13,7 +13,7 @@ describe("utils/googleCalendar", () => {
url: googleCalendarEvent.htmlLink,
description: "This is a description\nYep it is.",
minervaEventMetadata: {
channels: [slackChannels[0]],
channel: slackChannels[0],
meetingLink: "https://example.com",
},
location: googleCalendarEvent.location,
Expand All @@ -32,16 +32,16 @@ describe("utils/googleCalendar", () => {
"https://example.com",
);
event.minervaEventMetadata = {
channels: [slackChannels[0]],
channel: slackChannels[0],
meetingLink: "https://example.com",
};

it("should parse a Google Calendar event with one channel specified", () => {
expect(parseEventsOfChannels([event], [slackChannels[0].name])).toEqual([event]);
expect(filterEventsForChannels([event], [slackChannels[0].name])).toEqual([event]);
});

it("should return empty if no calendar events match the specified channel", () => {
expect(parseEventsOfChannels([event], [slackChannels[1].name])).toEqual([]);
expect(filterEventsForChannels([event], [slackChannels[1].name])).toEqual([]);
});
});
});
16 changes: 8 additions & 8 deletions tests/unit/utils/meetingReminders.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ describe("utils/eventReminders", () => {
jest.useFakeTimers().setSystemTime(new Date("2023-01-01T00:00:00.000Z").getTime());
event.location = "Test location";
event.minervaEventMetadata = {
channels: [slackChannels[0]],
channel: slackChannels[0],
meetingLink: "https://example.com",
};
const result = generateEventReminderText(event, EventReminderType.SIX_HOURS);
Expand All @@ -162,7 +162,7 @@ Ways to attend:
jest.useFakeTimers().setSystemTime(new Date("2023-01-01T05:55:00.000Z").getTime());
event.location = "Test location";
event.minervaEventMetadata = {
channels: [slackChannels[0]],
channel: slackChannels[0],
meetingLink: "https://example.com",
};
const result = generateEventReminderText(event, EventReminderType.FIVE_MINUTES);
Expand All @@ -180,7 +180,7 @@ Ways to attend:
it("should generate a reminder for 6 hours with no meeting link or location provided", () => {
jest.useFakeTimers().setSystemTime(new Date("2023-01-01T00:00:00.000Z").getTime());
event.minervaEventMetadata = {
channels: [slackChannels[0]],
channel: slackChannels[0],
};
const result = generateEventReminderText(event, EventReminderType.SIX_HOURS);

Expand All @@ -195,7 +195,7 @@ Ways to attend:
it("should generate a reminder for 5 minutes with no meeting link or location provided", () => {
jest.useFakeTimers().setSystemTime(new Date("2023-01-01T05:55:00.000Z").getTime());
event.minervaEventMetadata = {
channels: [slackChannels[0]],
channel: slackChannels[0],
};
const result = generateEventReminderText(event, EventReminderType.FIVE_MINUTES);

Expand All @@ -212,7 +212,7 @@ Ways to attend:
jest.useFakeTimers().setSystemTime(new Date("2023-01-01T00:00:00.000Z").getTime());
event.location = "Test location";
event.minervaEventMetadata = {
channels: [slackChannels[0]],
channel: slackChannels[0],
};
const result = generateEventReminderText(event, EventReminderType.SIX_HOURS);

Expand All @@ -228,7 +228,7 @@ Ways to attend:
it("should generate a reminder for 5 minutes with only location provided", () => {
jest.useFakeTimers().setSystemTime(new Date("2023-01-01T05:55:00.000Z").getTime());
event.minervaEventMetadata = {
channels: [slackChannels[0]],
channel: slackChannels[0],
};
event.location = "Test location";
const result = generateEventReminderText(event, EventReminderType.FIVE_MINUTES);
Expand All @@ -246,7 +246,7 @@ Ways to attend:
it("should generate a reminder for 6 hours with only meeting link provided", () => {
jest.useFakeTimers().setSystemTime(new Date("2023-01-01T00:00:00.000Z").getTime());
event.minervaEventMetadata = {
channels: [slackChannels[0]],
channel: slackChannels[0],
meetingLink: "https://example.com",
};
const result = generateEventReminderText(event, EventReminderType.SIX_HOURS);
Expand All @@ -262,7 +262,7 @@ Ways to attend:
it("should generate a reminder for 5 minutes with only meeting link provided", () => {
jest.useFakeTimers().setSystemTime(new Date("2023-01-01T05:55:00.000Z").getTime());
event.minervaEventMetadata = {
channels: [slackChannels[0]],
channel: slackChannels[0],
meetingLink: "https://example.com",
};
const result = generateEventReminderText(event, EventReminderType.FIVE_MINUTES);
Expand Down

0 comments on commit 8cb94ea

Please sign in to comment.