@tryghost/email-mock-receiver 0.2.3 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,13 +14,7 @@ class EmailMockReceiver {
14
14
  /**
15
15
  * Method mocking email sending logic
16
16
  *
17
- * @param {Object} message
18
- * @param {string} message.subject - email subject
19
- * @param {string} message.html - email content
20
- * @param {string} message.to - email recipient address
21
- * @param {string} [message.replyTo]
22
- * @param {string} [message.from] - sender email address
23
- * @param {string} [message.text] - text version of this message
17
+ * @param {EmailMessage} message - email message
24
18
  */
25
19
  async send(message) {
26
20
  // store snapshot
@@ -29,7 +23,21 @@ class EmailMockReceiver {
29
23
  return this.#sendResponse;
30
24
  }
31
25
 
32
- sentEmailCount(count) {
26
+ /**
27
+ *
28
+ * @param {Number} [index] zero-based index of the sent email
29
+ * @returns {EmailMessage}
30
+ */
31
+ getSentEmail(index = 0) {
32
+ return this.#snapshots[index];
33
+ }
34
+
35
+ /**
36
+ *
37
+ * @param {Number} count number of sent emails to expect
38
+ * @returns {EmailMockReceiver} current instance
39
+ */
40
+ assertSentEmailCount(count) {
33
41
  assert.equal(this.#snapshots.length, count, 'Email count does not match');
34
42
 
35
43
  return this;
@@ -123,3 +131,13 @@ module.exports = EmailMockReceiver;
123
131
  * @prop {String|RegExp} [pattern] - pattern to match the dynamic content
124
132
  * @prop {String} [replacement] - replacement for the matched pattern
125
133
  */
134
+
135
+ /**
136
+ * @typedef {Object} EmailMessage
137
+ * @prop {String} subject - email subject
138
+ * @prop {String} html - email HTML content
139
+ * @prop {String} to - email recipient address
140
+ * @prop {String} [replyTo] - email reply-to address
141
+ * @prop {String} [from] - sender email address
142
+ * @prop {String} [text] - text version of email message
143
+ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryghost/email-mock-receiver",
3
- "version": "0.2.3",
3
+ "version": "0.3.1",
4
4
  "repository": "https://github.com/TryGhost/framework/tree/main/packages/email-mock-receiver",
5
5
  "author": "Ghost Foundation",
6
6
  "license": "MIT",
@@ -25,5 +25,5 @@
25
25
  "mocha": "10.2.0",
26
26
  "sinon": "15.0.3"
27
27
  },
28
- "gitHead": "2e7899ed169bdfbfa05b0126519e632d000aac6d"
28
+ "gitHead": "466dd7191bd5ee20eb188b06f8b09b6a425ea940"
29
29
  }