Skip to content

Commit b75d88a

Browse files
committed
fix(firestore-send-email): fixing tests
1 parent 66738b8 commit b75d88a

File tree

2 files changed

+55
-12
lines changed

2 files changed

+55
-12
lines changed

firestore-send-email/functions/__tests__/helpers.test.ts

+28
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ const regex = new RegExp(
1414
describe("setSmtpCredentials function", () => {
1515
test("return smtpServerDomain credentials with new password", () => {
1616
const config: Config = {
17+
database: "fake-database",
18+
databaseRegion: "us-central1",
1719
smtpConnectionUri:
1820
1921
smtpPassword: "fakepassword",
@@ -35,6 +37,8 @@ describe("setSmtpCredentials function", () => {
3537

3638
test("return smtpServerDomain credentials with old password", () => {
3739
const config: Config = {
40+
database: "fake-database",
41+
databaseRegion: "us-central1",
3842
smtpConnectionUri:
3943
4044
location: "",
@@ -56,6 +60,8 @@ describe("setSmtpCredentials function", () => {
5660

5761
test("return smtpConnectionUri credentials without any password", () => {
5862
const config: Config = {
63+
database: "fake-database",
64+
databaseRegion: "us-central1",
5965
smtpConnectionUri: "smtps://[email protected]@smtp.gmail.com:465",
6066
location: "",
6167
mailCollection: "",
@@ -76,6 +82,8 @@ describe("setSmtpCredentials function", () => {
7682

7783
test("return smtpConnectionUri credentials without any password and username", () => {
7884
const config: Config = {
85+
database: "fake-database",
86+
databaseRegion: "us-central1",
7987
smtpConnectionUri: "smtp://smtp.gmail.com:465",
8088
location: "",
8189
mailCollection: "",
@@ -95,6 +103,8 @@ describe("setSmtpCredentials function", () => {
95103

96104
test("return smtpConnectionUri credentials with query params", () => {
97105
const config: Config = {
106+
database: "fake-database",
107+
databaseRegion: "us-central1",
98108
smtpConnectionUri:
99109
"smtp://[email protected]:[email protected]:465?pool=true&service=gmail",
100110
location: "",
@@ -118,6 +128,8 @@ describe("setSmtpCredentials function", () => {
118128

119129
test("return valid smtpConnectionUri credentials with valid special chars in password", () => {
120130
const config: Config = {
131+
database: "fake-database",
132+
databaseRegion: "us-central1",
121133
smtpConnectionUri:
122134
"smtp://[email protected]@smtp.gmail.com:465?pool=true&service=gmail",
123135
smtpPassword: "4,h?dhuNTbv9zMrP4&7&7%*3",
@@ -142,6 +154,8 @@ describe("setSmtpCredentials function", () => {
142154

143155
test("return valid smtpConnectionUri credentials with valid special chars in connectionUri password", () => {
144156
const config: Config = {
157+
database: "fake-database",
158+
databaseRegion: "us-central1",
145159
smtpConnectionUri:
146160
"smtp://[email protected]:4,hdhuNTbv9zMrP4&7&7%*[email protected]:465?pool=true&service=gmail",
147161
location: "",
@@ -166,6 +180,8 @@ describe("setSmtpCredentials function", () => {
166180

167181
test("throw error for invalid smtpConnectionUri", () => {
168182
const config: Config = {
183+
database: "fake-database",
184+
databaseRegion: "us-central1",
169185
smtpConnectionUri:
170186
"smtp://[email protected]:4,h?dhuNTbv9zMrP4&7&7%*[email protected]:465?pool=true&service=gmail",
171187
location: "",
@@ -184,6 +200,8 @@ describe("setSmtpCredentials function", () => {
184200
describe("isSendGrid function", () => {
185201
test("return true for SendGrid SMTP URI", () => {
186202
const config: Config = {
203+
database: "fake-database",
204+
databaseRegion: "us-central1",
187205
smtpConnectionUri: "smtps://[email protected]:465",
188206
location: "",
189207
mailCollection: "",
@@ -196,6 +214,8 @@ describe("isSendGrid function", () => {
196214

197215
test("return false for non-SendGrid SMTP URI", () => {
198216
const config: Config = {
217+
database: "fake-database",
218+
databaseRegion: "us-central1",
199219
smtpConnectionUri:
200220
201221
location: "",
@@ -210,6 +230,8 @@ describe("isSendGrid function", () => {
210230

211231
test("return invalid smtpConnectionUri credentials with invalid separator", () => {
212232
const config: Config = {
233+
database: "fake-database",
234+
databaseRegion: "us-central1",
213235
smtpConnectionUri:
214236
"smtp://[email protected]:4,h?dhuNTbv9zMrP4&7&7%*3:smtp.gmail.com:465?pool=true&service=gmail",
215237
location: "",
@@ -224,6 +246,8 @@ test("return invalid smtpConnectionUri credentials with invalid separator", () =
224246

225247
test("correctly detects SendGrid SMTP URI", () => {
226248
const config: Config = {
249+
database: "fake-database",
250+
databaseRegion: "us-central1",
227251
smtpConnectionUri: "smtps://[email protected]:465",
228252
location: "",
229253
mailCollection: "",
@@ -234,6 +258,8 @@ test("correctly detects SendGrid SMTP URI", () => {
234258
expect(isSendGrid(config)).toBe(true);
235259

236260
const invalidConfig: Config = {
261+
database: "fake-database",
262+
databaseRegion: "us-central1",
237263
smtpConnectionUri: "smtps://[email protected]:465",
238264
location: "",
239265
mailCollection: "",
@@ -246,6 +272,8 @@ test("correctly detects SendGrid SMTP URI", () => {
246272

247273
test("correctly uses oAuth credentials when provided", () => {
248274
const config: Config = {
275+
database: "fake-database",
276+
databaseRegion: "us-central1",
249277
smtpConnectionUri:
250278
251279
location: "",

firestore-send-email/functions/package-lock.json

+27-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)