Skip to content

Commit d7559c9

Browse files
committed
fix broken tests
1 parent 2bef658 commit d7559c9

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

tests/general/notifyer.test.ts

+19-15
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ async function createSection(
5959
}
6060

6161
const mockSendNotificationText = jest.fn(() => {
62+
console.log("I SHOULD BE CALLED");
6263
return Promise.resolve();
6364
});
6465

@@ -216,11 +217,12 @@ describe("Notifyer", () => {
216217
let notificationInfo: NotificationInfo;
217218
let courseHashToUsers: Record<string, User[]>;
218219
let sectionHashToUsers: Record<string, User[]>;
219-
it("does not send anything where there are no updated courses and sections", () => {
220+
it("does not send anything where there are no updated courses and sections", async () => {
220221
notificationInfo = { updatedCourses: [], updatedSections: [] };
221222
courseHashToUsers = {};
222223
sectionHashToUsers = {};
223-
sendNotifications(
224+
225+
await sendNotifications(
224226
notificationInfo,
225227
courseHashToUsers,
226228
sectionHashToUsers
@@ -294,14 +296,12 @@ describe("Notifyer", () => {
294296
data: {
295297
courseHash: "neu.edu/202210/ARTF/1122",
296298
userId: 1,
297-
notifCount: 0,
298299
},
299300
});
300301
await prisma.followedCourse.create({
301302
data: {
302303
courseHash: "neu.edu/202210/ARTF/1122",
303304
userId: 2,
304-
notifCount: 0,
305305
},
306306
});
307307
await prisma.followedCourse.create({
@@ -326,15 +326,15 @@ describe("Notifyer", () => {
326326
},
327327
});
328328

329-
sendNotifications(
329+
await sendNotifications(
330330
notificationInfo,
331331
courseHashToUsers,
332332
sectionHashToUsers
333333
);
334334
expect(mockSendNotificationText).toBeCalledTimes(5);
335335
});
336336

337-
it("does not send a notification if no users are subscribed to the updated course/section", () => {
337+
it("does not send a notification if no users are subscribed to the updated course/section", async () => {
338338
notificationInfo = {
339339
updatedCourses: [
340340
{
@@ -371,15 +371,16 @@ describe("Notifyer", () => {
371371
{ id: 2, phoneNumber: "+19879879876" },
372372
],
373373
};
374-
sendNotifications(
374+
await sendNotifications(
375375
notificationInfo,
376376
courseHashToUsers,
377377
sectionHashToUsers
378378
);
379379
expect(mockSendNotificationText).toBeCalledTimes(0);
380380
});
381381

382-
it("sends a properly formatted message when a new section is added to a course", () => {
382+
it("sends a properly formatted message when a new section is added to a course", async () => {
383+
console.log("INSIDE TEST 2");
383384
notificationInfo = {
384385
updatedCourses: [
385386
{
@@ -397,7 +398,7 @@ describe("Notifyer", () => {
397398
"neu.edu/202210/ARTF/1122": [{ id: 1, phoneNumber: "+11231231234" }],
398399
};
399400
sectionHashToUsers = {};
400-
sendNotifications(
401+
await sendNotifications(
401402
notificationInfo,
402403
courseHashToUsers,
403404
sectionHashToUsers
@@ -410,7 +411,8 @@ describe("Notifyer", () => {
410411
);
411412
});
412413

413-
it("sends a properly formatted message when multiple sections are added to a course", () => {
414+
it("sends a properly formatted message when multiple sections are added to a course", async () => {
415+
console.log("INSIDE TEST 3");
414416
notificationInfo = {
415417
updatedCourses: [
416418
{
@@ -428,7 +430,7 @@ describe("Notifyer", () => {
428430
"neu.edu/202210/ARTF/1122": [{ id: 1, phoneNumber: "+11231231234" }],
429431
};
430432
sectionHashToUsers = {};
431-
sendNotifications(
433+
await sendNotifications(
432434
notificationInfo,
433435
courseHashToUsers,
434436
sectionHashToUsers
@@ -441,7 +443,8 @@ describe("Notifyer", () => {
441443
);
442444
});
443445

444-
it("sends a properly formatted message when seats open up in a section", () => {
446+
it("sends a properly formatted message when seats open up in a section", async () => {
447+
console.log("INSIDE TEST 4");
445448
notificationInfo = {
446449
updatedCourses: [],
447450
updatedSections: [
@@ -462,7 +465,7 @@ describe("Notifyer", () => {
462465
{ id: 1, phoneNumber: "+11231231234" },
463466
],
464467
};
465-
sendNotifications(
468+
await sendNotifications(
466469
notificationInfo,
467470
courseHashToUsers,
468471
sectionHashToUsers
@@ -475,7 +478,8 @@ describe("Notifyer", () => {
475478
);
476479
});
477480

478-
it("sends a properly formatted message when waitlist seats open up in a section", () => {
481+
it("sends a properly formatted message when waitlist seats open up in a section", async () => {
482+
console.log("INSIDE TEST 5");
479483
notificationInfo = {
480484
updatedCourses: [],
481485
updatedSections: [
@@ -496,7 +500,7 @@ describe("Notifyer", () => {
496500
{ id: 1, phoneNumber: "+11231231234" },
497501
],
498502
};
499-
sendNotifications(
503+
await sendNotifications(
500504
notificationInfo,
501505
courseHashToUsers,
502506
sectionHashToUsers

0 commit comments

Comments
 (0)