Skip to content

Commit 81b40f0

Browse files
committed
fix code
1 parent 5c0dc1f commit 81b40f0

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

tests/general/twilio.test.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ describe("TwilioNotifyer", () => {
8888
mockRes.send.mockClear();
8989
});
9090

91-
it("should handle unknown user replies", () => {
91+
it("should handle unknown user replies", async () => {
9292
const req: Partial<express.Request> = {
9393
body: {
9494
Body: "this is a fake message that means nothing",
@@ -97,23 +97,23 @@ describe("TwilioNotifyer", () => {
9797
};
9898

9999
// @ts-expect-error - it's not the exact same type, but I don't care
100-
notifs.handleUserReply(req, mockRes);
100+
await notifs.handleUserReply(req, mockRes);
101101
expect(mockRes.send.mock.calls[0][0]).toMatch(
102102
/failed to understand your message/i,
103103
);
104104
});
105105

106-
it("should handle a 'Stop all' request", () => {
106+
it("should handle a 'Stop all' request", async () => {
107107
const req: Partial<express.Request> = {
108108
body: {
109109
Body: notifs.TWILIO_REPLIES["STOP_ALL"],
110110
From: "911",
111111
},
112112
};
113113

114-
const deleteSpy = jest.spyOn(notificationsManager, "deleteAllUserSubscriptions");
114+
const deleteSpy = jest.spyOn(notificationsManager, "deleteAllUserSubscriptions").mockResolvedValue(undefined);;
115115
// @ts-expect-error - it's not the exact same type, but I don't care
116-
notifs.handleUserReply(req, mockRes);
116+
await notifs.handleUserReply(req, mockRes);
117117
expect(deleteSpy).toHaveBeenCalledWith("911");
118118
expect(mockRes.send.mock.calls[0][0]).toMatch(/have been removed/i);
119119
});

twilio/notifs.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class TwilioNotifyer {
151151
});
152152
}
153153

154-
handleUserReply(req: express.Request, res: express.Response): void {
154+
async handleUserReply(req: express.Request, res: express.Response): Promise<void> {
155155
const message = req.body.Body;
156156
const senderNumber = req.body.From;
157157

@@ -165,7 +165,7 @@ class TwilioNotifyer {
165165
twimlResponse.message(
166166
"You have been removed from all SearchNEU notifications.",
167167
);
168-
notificationsManager.deleteAllUserSubscriptions(senderNumber);
168+
await notificationsManager.deleteAllUserSubscriptions(senderNumber);
169169
break;
170170
default:
171171
twimlResponse.message(

0 commit comments

Comments
 (0)