Skip to content

Commit

Permalink
replace deprecated jest methods
Browse files Browse the repository at this point in the history
  • Loading branch information
f-w committed Dec 5, 2024
1 parent 9874ccf commit 456ea99
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 94 deletions.
8 changes: 4 additions & 4 deletions test/cron.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ describe('CRON checkRssConfigUpdates', function () {
fail(err);
}
await wait(1000);
expect(fetch as unknown as jest.SpyInstance).toBeCalledWith(
expect(fetch as unknown as jest.SpyInstance).toHaveBeenCalledWith(
'http://foo/api/notifications',
expect.objectContaining({
method: 'POST',
Expand Down Expand Up @@ -495,7 +495,7 @@ describe('CRON checkRssConfigUpdates', function () {
await rssService.create(data);
await cronTasksService.checkRssConfigUpdates(true);
await wait(2000);
expect(fetch as unknown as jest.SpyInstance).not.toBeCalledWith(
expect(fetch as unknown as jest.SpyInstance).not.toHaveBeenCalledWith(
expect.any(String),
expect.objectContaining({ method: 'POST' }),
);
Expand Down Expand Up @@ -546,7 +546,7 @@ describe('CRON checkRssConfigUpdates', function () {
.mockReturnValueOnce(null);
await cronTasksService.checkRssConfigUpdates(true);
await wait(1000);
expect(loggerErrorSpy).toBeCalledWith(
expect(loggerErrorSpy).toHaveBeenCalledWith(
expect.objectContaining({
message: 'Bad status code',
}),
Expand Down Expand Up @@ -658,7 +658,7 @@ describe('CRON reDispatchBroadcastPushNotifications', () => {
await wait(3000);
const mockedSendEmail = CommonService.prototype
.sendEmail as unknown as jest.SpyInstance;
expect(mockedSendEmail).toBeCalledWith(
expect(mockedSendEmail).toHaveBeenCalledWith(
expect.objectContaining({
from: '[email protected]',
to: '[email protected]',
Expand Down
42 changes: 21 additions & 21 deletions test/inbound-smtp-server.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describe('list-unsubscribe by email', function () {
expect(info.accepted.length).toEqual(1);
expect(smtpSvr.onRcptTo).toHaveBeenCalled();
expect(smtpSvr.onData).toHaveBeenCalled();
expect(fetch as unknown as jest.SpyInstance).toBeCalledWith(
expect(fetch as unknown as jest.SpyInstance).toHaveBeenCalledWith(
`http://localhost:3000/api/subscriptions/${subId}/unsubscribe?unsubscriptionCode=12345&userChannelId=bar%40foo.com`,
{
headers: {
Expand All @@ -123,8 +123,8 @@ describe('list-unsubscribe by email', function () {
} catch (err) {
expect(err.rejected.length).toEqual(1);
}
expect(smtpSvr.onRcptTo).toBeCalled;
expect(smtpSvr.onData).not.toBeCalled();
expect(smtpSvr.onRcptTo).toHaveBeenCalled;
expect(smtpSvr.onData).not.toHaveBeenCalled();
connection.quit();
});

Expand All @@ -141,8 +141,8 @@ describe('list-unsubscribe by email', function () {
} catch (err) {
expect(err.rejected.length).toEqual(1);
}
expect(smtpSvr.onRcptTo).toBeCalled();
expect(smtpSvr.onData).not.toBeCalled();
expect(smtpSvr.onRcptTo).toHaveBeenCalled();
expect(smtpSvr.onData).not.toHaveBeenCalled();
connection.quit();
});
});
Expand Down Expand Up @@ -219,8 +219,8 @@ describe('bounce', function () {
`Received: from localhost (localhost)\r\n\tby foo.invalid.local (8.14.4/8.14.4) id w7TItYs4100793;\r\n\tWed, 29 Aug 2018 11:55:34 -0700\r\nDate: Wed, 29 Aug 2018 11:55:34 -0700\r\nFrom: Mail Delivery Subsystem <[email protected]>\r\nMessage-Id: <[email protected]>\r\nTo: <[email protected]>\r\nMIME-Version: 1.0\r\nContent-Type: multipart/report; report-type=delivery-status;\r\n\tboundary="w7TItYs4100793.1535568934/foo.invalid.local"\r\nSubject: Returned mail: see transcript for details\r\nAuto-Submitted: auto-generated (failure)\r\n\r\nThis is a MIME-encapsulated message\r\n\r\n--w7TItYs4100793.1535568934/foo.invalid.local\r\n\r\nThe original message was received at Wed, 29 Aug 2018 11:55:34 -0700\r\nfrom invalid.local [0.0.0.0]\r\n\r\n ----- The following addresses had permanent fatal errors -----\r\n<[email protected]>\r\n (reason: 550-5.1.1 The email account that you tried to reach does not exist. Please try)\r\n\r\n ----- Transcript of session follows -----\r\n... while talking to gmail-smtp-in.l.google.com.:\r\n>>> DATA\r\n<<< 550-5.1.1 The email account that you tried to reach does not exist. Please try\r\n<<< 550-5.1.1 double-checking the recipient's email address for typos or\r\n<<< 550-5.1.1 unnecessary spaces. Learn more at\r\n<<< 550 5.1.1 https://support.google.com/mail/?p=NoSuchUser c17-v6si4448431pge.273 - gsmtp\r\n550 5.1.1 <[email protected]>... User unknown\r\n<<< 503 5.5.1 RCPT first. c17-v6si4448431pge.273 - gsmtp\r\n\r\n--w7TItYs4100793.1535568934/foo.invalid.local\r\nContent-Type: message/delivery-status\r\n\r\nReporting-MTA: dns; foo.invalid.local\r\nReceived-From-MTA: DNS; invalid.local\r\nArrival-Date: Wed, 29 Aug 2018 11:55:34 -0700\r\n\r\nFinal-Recipient: RFC822; [email protected]\r\nAction: failed\r\nStatus: 5.1.1\r\nRemote-MTA: DNS; gmail-smtp-in.l.google.com\r\nDiagnostic-Code: SMTP; 550-5.1.1 The email account that you tried to reach does not exist. Please try\r\nLast-Attempt-Date: Wed, 29 Aug 2018 11:55:34 -0700\r\n\r\n--w7TItYs4100793.1535568934/foo.invalid.local\r\nContent-Type: message/rfc822\r\n\r\nReturn-Path: <[email protected]>\r\nReceived: from [127.0.0.1] (invalid.local [0.0.0.0])\r\n\tby foo.invalid.local (8.14.4/8.14.4) with ESMTP id w7TIqOs6099075\r\n\t(version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO)\r\n\tfor <[email protected]>; Wed, 29 Aug 2018 11:55:34 -0700\r\nDKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r\n d=mail.www2.invalid.local; q=dns/txt; s=dev;\r\n bh=wrkCugmpWjuk1K/MNn64VeMFmvd+ef1KHXTHHL+GO84=;\r\n h=from:subject:date:message-id:to:mime-version:content-type:list-id:list-unsubscribe;\r\n b=O5i568MBJIL38+umlZxJGAG+vffxe89cbUNbCrjt/QDHRiiLBcLpZBMPTqvQnEJX6gwLXnBkj\r\n m/69oke2/HmSTp9T/I0MmwenuqpEc7lhCeMfCvS19PTaQKb5tb/EK+TQt516yre3ElkCXrr/lyg\r\n PPrZozr8rupPNhK5NZNpABJXQtCQEfdF8Fw7OnHWalvch7Q5jfta84EQ6zOGAC6HfLFe0O/VkVf\r\n sbEwGGyC9OOEyGBpppEMBGx8qXuZxSpxiaWGdGVhW6jf/WLghPwThvDgRYSq9jTNfenMXR2LAPf\r\n FbjSR6GqrRowS4h2GVVyPTYk1SGT0uGJucNa/vlDWgnQ==\r\nContent-Type: multipart/alternative;\r\n boundary="--_NmP-6ea6170c81eda5cc-Part_1"\r\nFrom: [email protected]\r\nTo: [email protected]\r\nSubject: test\r\nMessage-ID: <[email protected]>\r\nList-ID: <https://invalid.local/test>\r\nList-Unsubscribe: <mailto:[email protected]>, <https://invalid.local/notifybc/api/subscriptions/5b50cb6e953d170b24983019/unsubscribe?unsubscriptionCode=42074>\r\nDate: Wed, 29 Aug 2018 18:55:34 +0000\r\nMIME-Version: 1.0\r\nX-Scanned-By: MIMEDefang 2.70 on 0.0.0.0\r\n\r\n----_NmP-6ea6170c81eda5cc-Part_1\r\nContent-Type: text/plain\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\nThis is a test https://invalid.local/notifybc/api/subscriptions/5b50c=\r\nb6e953d170b24983019/unsubscribe?unsubscriptionCode=3D42074\r\n----_NmP-6ea6170c81eda5cc-Part_1\r\nContent-Type: text/html\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\nThis is a test.\r\n----_NmP-6ea6170c81eda5cc-Part_1--\r\n\r\n--w7TItYs4100793.1535568934/foo.invalid.local--\r\n\r\n`,
);
expect(info.accepted.length).toEqual(1);
expect(smtpSvr.onRcptTo).toBeCalled();
expect(smtpSvr.onData).toBeCalled();
expect(smtpSvr.onRcptTo).toHaveBeenCalled();
expect(smtpSvr.onData).toHaveBeenCalled();
connection.quit();
});
});
Expand Down Expand Up @@ -277,8 +277,8 @@ describe('bounce', function () {
`Received: from localhost (localhost)\r\n\tby foo.invalid.local (8.14.4/8.14.4) id w7TItYs4100793;\r\n\tWed, 29 Aug 2018 11:55:34 -0700\r\nDate: Wed, 29 Aug 2018 11:55:34 -0700\r\nFrom: Mail Delivery Subsystem <[email protected]>\r\nMessage-Id: <[email protected]>\r\nTo: <[email protected]>\r\nMIME-Version: 1.0\r\nContent-Type: multipart/report; report-type=delivery-status;\r\n\tboundary="w7TItYs4100793.1535568934/foo.invalid.local"\r\nSubject: Returned mail: see transcript for details\r\nAuto-Submitted: auto-generated (failure)\r\n\r\nThis is a MIME-encapsulated message\r\n\r\n--w7TItYs4100793.1535568934/foo.invalid.local\r\nContent-Type: message/delivery-status\r\n\r\nReporting-MTA: dns; foo.invalid.local\r\nReceived-From-MTA: DNS; invalid.local\r\nArrival-Date: Wed, 29 Aug 2018 11:55:34 -0700\r\n\r\nFinal-Recipient: RFC822; [email protected]\r\nAction: failed\r\nStatus: 5.1.1\r\nRemote-MTA: DNS; gmail-smtp-in.l.google.com\r\nDiagnostic-Code: SMTP; 550-5.1.1 The email account that you tried to reach does not exist. Please try\r\nLast-Attempt-Date: Wed, 29 Aug 2018 11:55:34 -0700\r\n\r\n--w7TItYs4100793.1535568934/foo.invalid.local--\r\n\r\n`,
);
expect(info.accepted.length).toEqual(1);
expect(smtpSvr.onRcptTo).toBeCalled();
expect(smtpSvr.onData).toBeCalled();
expect(smtpSvr.onRcptTo).toHaveBeenCalled();
expect(smtpSvr.onData).toHaveBeenCalled();
connection.quit();
const rec = await bouncesService.findById(bounceId);
expect(rec.hardBounceCount).toEqual(2);
Expand Down Expand Up @@ -337,8 +337,8 @@ describe('bounce', function () {
`From: Mail Delivery Subsystem <[email protected]>\r\nMessage-Id: <[email protected]>\r\nTo: <[email protected]>\r\nMIME-Version: 1.0\r\nContent-Type: multipart/report; report-type=delivery-status;\r\n\tboundary="w7TItYs4100793.1535568934/foo.invalid.local"\r\nSubject: invalid\r\n\r\nThis is a MIME-encapsulated message\r\n\r\n--w7TItYs4100793.1535568934/foo.invalid.local\r\nContent-Type: message/delivery-status\r\n\r\nReporting-MTA: dns; foo.invalid.local\r\nReceived-From-MTA: DNS; invalid.local\r\nArrival-Date: Wed, 29 Aug 2018 11:55:34 -0700\r\n\r\nFinal-Recipient: RFC822; [email protected]\r\nAction: failed\r\nStatus: 5.1.1\r\nRemote-MTA: DNS; gmail-smtp-in.l.google.com\r\nDiagnostic-Code: SMTP; 550-5.1.1 The email account that you tried to reach does not exist. Please try\r\nLast-Attempt-Date: Wed, 29 Aug 2018 11:55:34 -0700\r\n\r\n--w7TItYs4100793.1535568934/foo.invalid.local--\r\n\r\n`,
);
expect(info.accepted.length).toEqual(1);
expect(smtpSvr.onRcptTo).toBeCalled();
expect(smtpSvr.onData).toBeCalled();
expect(smtpSvr.onRcptTo).toHaveBeenCalled();
expect(smtpSvr.onData).toHaveBeenCalled();
connection.quit();
const rec = await bouncesService.findById(bounceId);
expect(rec.hardBounceCount).toEqual(1);
Expand Down Expand Up @@ -397,8 +397,8 @@ describe('bounce', function () {
`From: Mail Delivery Subsystem <[email protected]>\r\nTo: <[email protected]>\r\nMIME-Version: 1.0\r\nContent-Type: multipart/report; report-type=delivery-status;\r\n\tboundary="w7TItYs4100793.1535568934/foo.invalid.local"\r\nSubject: Returned mail: see transcript for details\r\nAuto-Submitted: auto-generated (failure)\r\n\r\nThis is a MIME-encapsulated message\r\n\r\n--w7TItYs4100793.1535568934/foo.invalid.local\r\nContent-Type: message/delivery-status\r\n\r\nReporting-MTA: dns; foo.invalid.local\r\nReceived-From-MTA: DNS; invalid.local\r\nArrival-Date: Wed, 29 Aug 2018 11:55:34 -0700\r\n\r\nFinal-Recipient: RFC822; [email protected]\r\nAction: failed\r\nStatus: 4.1.1\r\n\r\n`,
);
expect(info.accepted.length).toEqual(1);
expect(smtpSvr.onRcptTo).toBeCalled();
expect(smtpSvr.onData).toBeCalled();
expect(smtpSvr.onRcptTo).toHaveBeenCalled();
expect(smtpSvr.onData).toHaveBeenCalled();
connection.quit();
const rec = await bouncesService.findById(bounceId);
expect(rec.hardBounceCount).toEqual(1);
Expand Down Expand Up @@ -457,8 +457,8 @@ describe('bounce', function () {
`From: Mail Delivery Subsystem <[email protected]>\r\nTo: <[email protected]>\r\nMIME-Version: 1.0\r\nContent-Type: multipart/report; report-type=delivery-status;\r\n\tboundary="w7TItYs4100793.1535568934/foo.invalid.local"\r\nSubject: Returned mail: see transcript for details\r\nAuto-Submitted: auto-generated (failure)\r\n\r\nThis is a MIME-encapsulated message\r\n\r\n--w7TItYs4100793.1535568934/foo.invalid.local\r\nContent-Type: message/delivery-status\r\n\r\nReporting-MTA: dns; foo.invalid.local\r\nReceived-From-MTA: DNS; invalid.local\r\nArrival-Date: Wed, 29 Aug 2018 11:55:34 -0700\r\n\r\nFinal-Recipient: RFC822; [email protected]\r\nAction: failed\r\nStatus: 5.1.1\r\n\r\n--w7TItYs4100793.1535568934/foo.invalid.local\r\n\r\n`,
);
expect(info.accepted.length).toEqual(1);
expect(smtpSvr.onRcptTo).toBeCalled();
expect(smtpSvr.onData).toBeCalled();
expect(smtpSvr.onRcptTo).toHaveBeenCalled();
expect(smtpSvr.onData).toHaveBeenCalled();
connection.quit();
const rec = await bouncesService.findById(bounceId);
expect(rec.hardBounceCount).toEqual(1);
Expand Down Expand Up @@ -517,8 +517,8 @@ describe('bounce', function () {
`From: Mail Delivery Subsystem <[email protected]>\r\nTo: <[email protected]>\r\nMIME-Version: 1.0\r\nContent-Type: multipart/report; report-type=delivery-status;\r\n\tboundary="w7TItYs4100793.1535568934/foo.invalid.local"\r\nSubject: Returned mail: see transcript for details\r\nX-Failed-Recipients: [email protected]\r\nAuto-Submitted: auto-generated (failure)\r\n\r\nThis is a MIME-encapsulated message\r\n\r\n--w7TItYs4100793.1535568934/foo.invalid.local\r\nContent-Type: message/delivery-status\r\n\r\nReporting-MTA: dns; foo.invalid.local\r\nReceived-From-MTA: DNS; invalid.local\r\nArrival-Date: Wed, 29 Aug 2018 11:55:34 -0700\r\n\r\nFinal-Recipient: RFC822; [email protected]\r\nAction: failed\r\nStatus: 5.1.1\r\n\r\n--w7TItYs4100793.1535568934/foo.invalid.local\r\n\r\n`,
);
expect(info.accepted.length).toEqual(1);
expect(smtpSvr.onRcptTo).toBeCalled();
expect(smtpSvr.onData).toBeCalled();
expect(smtpSvr.onRcptTo).toHaveBeenCalled();
expect(smtpSvr.onData).toHaveBeenCalled();
connection.quit();
const rec = await bouncesService.findById(bounceId);
expect(rec.hardBounceCount).toEqual(2);
Expand Down Expand Up @@ -583,8 +583,8 @@ describe('bounce', function () {
`Received: from localhost (localhost)\r\n\tby foo.invalid.local (8.14.4/8.14.4) id w7TItYs4100793;\r\n\tWed, 29 Aug 2018 11:55:34 -0700\r\nDate: Wed, 29 Aug 2018 11:55:34 -0700\r\nFrom: Mail Delivery Subsystem <[email protected]>\r\nMessage-Id: <[email protected]>\r\nTo: <[email protected]>\r\nMIME-Version: 1.0\r\nContent-Type: multipart/report; report-type=delivery-status;\r\n\tboundary="w7TItYs4100793.1535568934/foo.invalid.local"\r\nSubject: Returned mail: see transcript for details\r\nAuto-Submitted: auto-generated (failure)\r\n\r\nThis is a MIME-encapsulated message\r\n\r\n--w7TItYs4100793.1535568934/foo.invalid.local\r\n\r\nThe original message was received at Wed, 29 Aug 2018 11:55:34 -0700\r\nfrom invalid.local [0.0.0.0]\r\n\r\n ----- The following addresses had permanent fatal errors -----\r\n<[email protected]>\r\n (reason: 550-5.1.1 The email account that you tried to reach does not exist. Please try)\r\n\r\n ----- Transcript of session follows -----\r\n... while talking to gmail-smtp-in.l.google.com.:\r\n>>> DATA\r\n<<< 550-5.1.1 The email account that you tried to reach does not exist. Please try\r\n<<< 550-5.1.1 double-checking the recipient's email address for typos or\r\n<<< 550-5.1.1 unnecessary spaces. Learn more at\r\n<<< 550 5.1.1 https://support.google.com/mail/?p=NoSuchUser c17-v6si4448431pge.273 - gsmtp\r\n550 5.1.1 <[email protected]>... User unknown\r\n<<< 503 5.5.1 RCPT first. c17-v6si4448431pge.273 - gsmtp\r\n\r\n--w7TItYs4100793.1535568934/foo.invalid.local\r\nContent-Type: message/delivery-status\r\n\r\nReporting-MTA: dns; foo.invalid.local\r\nReceived-From-MTA: DNS; invalid.local\r\nArrival-Date: Wed, 29 Aug 2018 11:55:34 -0700\r\n\r\nFinal-Recipient: RFC822; [email protected]\r\nAction: failed\r\nStatus: 5.1.1\r\nRemote-MTA: DNS; gmail-smtp-in.l.google.com\r\nDiagnostic-Code: SMTP; 550-5.1.1 The email account that you tried to reach does not exist. Please try\r\nLast-Attempt-Date: Wed, 29 Aug 2018 11:55:34 -0700\r\n\r\n--w7TItYs4100793.1535568934/foo.invalid.local\r\nContent-Type: message/rfc822\r\n\r\nReturn-Path: <[email protected]>\r\nReceived: from [127.0.0.1] (invalid.local [0.0.0.0])\r\n\tby foo.invalid.local (8.14.4/8.14.4) with ESMTP id w7TIqOs6099075\r\n\t(version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO)\r\n\tfor <[email protected]>; Wed, 29 Aug 2018 11:55:34 -0700\r\nDKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r\n d=mail.www2.invalid.local; q=dns/txt; s=dev;\r\n bh=wrkCugmpWjuk1K/MNn64VeMFmvd+ef1KHXTHHL+GO84=;\r\n h=from:subject:date:message-id:to:mime-version:content-type:list-id:list-unsubscribe;\r\n b=O5i568MBJIL38+umlZxJGAG+vffxe89cbUNbCrjt/QDHRiiLBcLpZBMPTqvQnEJX6gwLXnBkj\r\n m/69oke2/HmSTp9T/I0MmwenuqpEc7lhCeMfCvS19PTaQKb5tb/EK+TQt516yre3ElkCXrr/lyg\r\n PPrZozr8rupPNhK5NZNpABJXQtCQEfdF8Fw7OnHWalvch7Q5jfta84EQ6zOGAC6HfLFe0O/VkVf\r\n sbEwGGyC9OOEyGBpppEMBGx8qXuZxSpxiaWGdGVhW6jf/WLghPwThvDgRYSq9jTNfenMXR2LAPf\r\n FbjSR6GqrRowS4h2GVVyPTYk1SGT0uGJucNa/vlDWgnQ==\r\nContent-Type: multipart/alternative;\r\n boundary="--_NmP-6ea6170c81eda5cc-Part_1"\r\nFrom: [email protected]\r\nTo: [email protected]\r\nSubject: test\r\nMessage-ID: <[email protected]>\r\nList-ID: <https://invalid.local/test>\r\nList-Unsubscribe: <mailto:[email protected]>, <https://invalid.local/notifybc/api/subscriptions/5b50cb6e953d170b24983019/unsubscribe?unsubscriptionCode=42074>\r\nDate: Wed, 29 Aug 2018 18:55:34 +0000\r\nMIME-Version: 1.0\r\nX-Scanned-By: MIMEDefang 2.70 on 0.0.0.0\r\n\r\n----_NmP-6ea6170c81eda5cc-Part_1\r\nContent-Type: text/plain\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\nThis is a test https://invalid.local/notifybc/api/subscriptions/5b50c=\r\nb6e953d170b24983019/unsubscribe?unsubscriptionCode=3D42074\r\n----_NmP-6ea6170c81eda5cc-Part_1\r\nContent-Type: text/html\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\nThis is a test.\r\n----_NmP-6ea6170c81eda5cc-Part_1--\r\n\r\n--w7TItYs4100793.1535568934/foo.invalid.local--\r\n\r\n`,
);
expect(info.accepted.length).toEqual(1);
expect(smtpSvr.onRcptTo).toBeCalled();
expect(smtpSvr.onData).toBeCalled();
expect(smtpSvr.onRcptTo).toHaveBeenCalled();
expect(smtpSvr.onData).toHaveBeenCalled();
connection.quit();
const rec = await bouncesService.findById(bounceId);
expect(rec.state).toEqual('deleted');
Expand All @@ -608,8 +608,8 @@ describe('bounce', function () {
} catch (err) {
expect(err.responseCode).toEqual(451);
}
expect(smtpSvr.onRcptTo).toBeCalled();
expect(smtpSvr.onData).toBeCalled();
expect(smtpSvr.onRcptTo).toHaveBeenCalled();
expect(smtpSvr.onData).toHaveBeenCalled();
connection.quit();
});
});
Loading

0 comments on commit 456ea99

Please sign in to comment.