@@ -3,7 +3,10 @@ import express from 'express';
3
3
import auth from './auth' ;
4
4
import request from 'supertest' ;
5
5
import notifications from './notifications' ;
6
- import { NotificationChannelType } from '@dm3-org/dm3-lib-delivery' ;
6
+ import {
7
+ DeliveryServiceProperties ,
8
+ NotificationChannelType ,
9
+ } from '@dm3-org/dm3-lib-delivery' ;
7
10
8
11
const keysA = {
9
12
encryptionKeyPair : {
@@ -20,19 +23,17 @@ const keysA = {
20
23
} ;
21
24
22
25
describe ( 'Notifications' , ( ) => {
23
- const getDeliveryServiceProperties = ( ) => {
24
- return {
25
- messageTTL : 12345 ,
26
- sizeLimit : 456 ,
27
- notificationChannel : [ ] ,
28
- } ;
26
+ const deliveryServiceProperties : DeliveryServiceProperties = {
27
+ messageTTL : 12345 ,
28
+ sizeLimit : 456 ,
29
+ notificationChannel : [ ] ,
29
30
} ;
30
31
31
32
describe ( 'get NotificationChannels' , ( ) => {
32
33
it ( 'Returns empty array as global notification is turned off' , async ( ) => {
33
34
const app = express ( ) ;
34
35
app . use ( bodyParser . json ( ) ) ;
35
- app . use ( notifications ( getDeliveryServiceProperties ) ) ;
36
+ app . use ( notifications ( deliveryServiceProperties ) ) ;
36
37
37
38
const token = await createAuthToken ( ) ;
38
39
@@ -81,7 +82,7 @@ describe('Notifications', () => {
81
82
it ( 'Returns 200 with empty notification channels as global notification is turned on' , async ( ) => {
82
83
const app = express ( ) ;
83
84
app . use ( bodyParser . json ( ) ) ;
84
- app . use ( notifications ( getDeliveryServiceProperties ) ) ;
85
+ app . use ( notifications ( deliveryServiceProperties ) ) ;
85
86
86
87
const token = await createAuthToken ( ) ;
87
88
@@ -132,7 +133,7 @@ describe('Notifications', () => {
132
133
it ( 'Returns 400 on setup email notifications as email ID is invalid' , async ( ) => {
133
134
const app = express ( ) ;
134
135
app . use ( bodyParser . json ( ) ) ;
135
- app . use ( notifications ( getDeliveryServiceProperties ) ) ;
136
+ app . use ( notifications ( deliveryServiceProperties ) ) ;
136
137
137
138
const token = await createAuthToken ( ) ;
138
139
const addUsersNotificationChannelMock = jest . fn ( ) ;
@@ -172,7 +173,7 @@ describe('Notifications', () => {
172
173
it ( 'Returns 400 on setup email notifications as notificationChannelType is invalid' , async ( ) => {
173
174
const app = express ( ) ;
174
175
app . use ( bodyParser . json ( ) ) ;
175
- app . use ( notifications ( getDeliveryServiceProperties ) ) ;
176
+ app . use ( notifications ( deliveryServiceProperties ) ) ;
176
177
177
178
const token = await createAuthToken ( ) ;
178
179
const addUsersNotificationChannelMock = jest . fn ( ) ;
@@ -212,7 +213,7 @@ describe('Notifications', () => {
212
213
it ( 'Returns 400 on setup email notifications as globalNotifications is turned off' , async ( ) => {
213
214
const app = express ( ) ;
214
215
app . use ( bodyParser . json ( ) ) ;
215
- app . use ( notifications ( getDeliveryServiceProperties ) ) ;
216
+ app . use ( notifications ( deliveryServiceProperties ) ) ;
216
217
217
218
const token = await createAuthToken ( ) ;
218
219
const addUsersNotificationChannelMock = jest . fn ( ) ;
@@ -252,28 +253,26 @@ describe('Notifications', () => {
252
253
} ) ;
253
254
254
255
it ( 'User can setup email notifications' , async ( ) => {
255
- const getDeliveryServiceProperties = ( ) => {
256
- return {
257
- messageTTL : 12345 ,
258
- sizeLimit : 456 ,
259
- notificationChannel : [
260
- {
261
- type : NotificationChannelType . EMAIL ,
262
- config : {
263
- smtpHost : 'smtp.gmail.com' ,
264
- smtpPort : 587 ,
265
-
266
- smtpUsername :
'[email protected] ' ,
267
- smtpPassword : 'abcd1234' ,
268
- } ,
256
+ const deliveryServiceProperties : DeliveryServiceProperties = {
257
+ messageTTL : 12345 ,
258
+ sizeLimit : 456 ,
259
+ notificationChannel : [
260
+ {
261
+ type : NotificationChannelType . EMAIL ,
262
+ config : {
263
+ smtpHost : 'smtp.gmail.com' ,
264
+ smtpPort : 587 ,
265
+
266
+ smtpUsername :
'[email protected] ' ,
267
+ smtpPassword : 'abcd1234' ,
269
268
} ,
270
- ] ,
271
- } ;
269
+ } ,
270
+ ] ,
272
271
} ;
273
272
274
273
const app = express ( ) ;
275
274
app . use ( bodyParser . json ( ) ) ;
276
- app . use ( notifications ( getDeliveryServiceProperties ) ) ;
275
+ app . use ( notifications ( deliveryServiceProperties ) ) ;
277
276
278
277
const token = await createAuthToken ( ) ;
279
278
@@ -330,7 +329,7 @@ describe('Notifications', () => {
330
329
it ( 'Returns 400 as Email notification channel is not supported in delivery service' , async ( ) => {
331
330
const app = express ( ) ;
332
331
app . use ( bodyParser . json ( ) ) ;
333
- app . use ( notifications ( getDeliveryServiceProperties ) ) ;
332
+ app . use ( notifications ( deliveryServiceProperties ) ) ;
334
333
335
334
const token = await createAuthToken ( ) ;
336
335
@@ -391,7 +390,7 @@ describe('Notifications', () => {
391
390
it ( 'Returns 200 and false as global notification is not enabled' , async ( ) => {
392
391
const app = express ( ) ;
393
392
app . use ( bodyParser . json ( ) ) ;
394
- app . use ( notifications ( getDeliveryServiceProperties ) ) ;
393
+ app . use ( notifications ( deliveryServiceProperties ) ) ;
395
394
396
395
const token = await createAuthToken ( ) ;
397
396
@@ -442,7 +441,7 @@ describe('Notifications', () => {
442
441
it ( 'Enable global notifications' , async ( ) => {
443
442
const app = express ( ) ;
444
443
app . use ( bodyParser . json ( ) ) ;
445
- app . use ( notifications ( getDeliveryServiceProperties ) ) ;
444
+ app . use ( notifications ( deliveryServiceProperties ) ) ;
446
445
447
446
const token = await createAuthToken ( ) ;
448
447
@@ -484,7 +483,7 @@ describe('Notifications', () => {
484
483
it ( 'Disable global notifications' , async ( ) => {
485
484
const app = express ( ) ;
486
485
app . use ( bodyParser . json ( ) ) ;
487
- app . use ( notifications ( getDeliveryServiceProperties ) ) ;
486
+ app . use ( notifications ( deliveryServiceProperties ) ) ;
488
487
489
488
const token = await createAuthToken ( ) ;
490
489
@@ -526,7 +525,7 @@ describe('Notifications', () => {
526
525
it ( 'Returns 400 if req.body is invalid' , async ( ) => {
527
526
const app = express ( ) ;
528
527
app . use ( bodyParser . json ( ) ) ;
529
- app . use ( notifications ( getDeliveryServiceProperties ) ) ;
528
+ app . use ( notifications ( deliveryServiceProperties ) ) ;
530
529
531
530
const token = await createAuthToken ( ) ;
532
531
0 commit comments