@@ -32,19 +32,21 @@ describe('The Notification API', (): void => {
32
32
33
33
it ( 'should send notifications' , async ( ) : Promise < void > => {
34
34
const notification = new Notification ( configuration , '' , confluence , transportStub )
35
- const documentInfo = new DocumentInfo ( 0 , 'author' , moment ( ) , 'message' , 'title' , [ 'main' ] , 'http://example.com' )
35
+ const documentInfo = new DocumentInfo ( 0 , 'author' , moment ( ) , 'message' , 'title' , [ 'main' ] , 'http://example.com' , 'test' )
36
36
await notification . notify ( [ documentInfo ] )
37
37
chai . expect ( ( transportStub as unknown as SinonStubbedInstance < Mail > ) . sendMail . calledOnce ) . to . be . true
38
38
chai . expect (
39
39
( transportStub as unknown as SinonStubbedInstance < Mail > ) . sendMail . calledWith ( {
40
40
from :
'Notification <[email protected] >' ,
41
41
42
42
subject : Handlebars . compile ( MockServer . NOTIFICATION_SUBJECT ) ( {
43
+
43
44
documentsCount : 1 ,
44
45
documents : [ documentInfo ] ,
45
46
multipleDocuments : false ,
46
47
} ) ,
47
48
html : Handlebars . compile ( MockServer . NOTIFICATION_BODY ) ( {
49
+
48
50
documentsCount : 1 ,
49
51
documents : [ documentInfo ] ,
50
52
multipleDocuments : false ,
@@ -54,19 +56,21 @@ describe('The Notification API', (): void => {
54
56
} )
55
57
it ( 'should use a maintainer when configured' , async ( ) : Promise < void > => {
56
58
const notification = new Notification ( configuration , '' , confluence , transportStub )
57
- const documentInfo = new DocumentInfo ( 0 , 'author2' , moment ( ) , 'message' , 'Test2' , [ 'main' , 'Test' ] , 'http://example.com' )
59
+ const documentInfo = new DocumentInfo ( 0 , 'author2' , moment ( ) , 'message' , 'Test2' , [ 'main' , 'Test' ] , 'http://example.com' , 'test' )
58
60
await notification . notify ( [ documentInfo ] )
59
61
chai . expect ( ( transportStub as unknown as SinonStubbedInstance < Mail > ) . sendMail . calledTwice ) . to . be . true
60
62
chai . expect (
61
63
( transportStub as unknown as SinonStubbedInstance < Mail > ) . sendMail . calledWith ( {
62
64
from :
'Notification <[email protected] >' ,
63
65
64
66
subject : Handlebars . compile ( MockServer . NOTIFICATION_SUBJECT ) ( {
67
+
65
68
documentsCount : 1 ,
66
69
documents : [ documentInfo ] ,
67
70
multipleDocuments : false ,
68
71
} ) ,
69
72
html : Handlebars . compile ( MockServer . NOTIFICATION_BODY ) ( {
73
+
70
74
documentsCount : 1 ,
71
75
documents : [ documentInfo ] ,
72
76
multipleDocuments : false ,
@@ -78,11 +82,13 @@ describe('The Notification API', (): void => {
78
82
from :
'Notification <[email protected] >' ,
79
83
80
84
subject : Handlebars . compile ( MockServer . NOTIFICATION_SUBJECT ) ( {
85
+
81
86
documentsCount : 1 ,
82
87
documents : [ documentInfo ] ,
83
88
multipleDocuments : false ,
84
89
} ) ,
85
90
html : Handlebars . compile ( MockServer . NOTIFICATION_BODY ) ( {
91
+
86
92
documentsCount : 1 ,
87
93
documents : [ documentInfo ] ,
88
94
multipleDocuments : false ,
@@ -92,33 +98,35 @@ describe('The Notification API', (): void => {
92
98
} )
93
99
it ( 'should not send notifications on a dry run' , async ( ) : Promise < void > => {
94
100
const notification = new Notification ( configuration , '' , confluence , transportStub , true )
95
- const documentInfo = new DocumentInfo ( 0 , 'author' , moment ( ) , 'message' , 'title' , [ 'main' ] , 'http://example.com' )
101
+ const documentInfo = new DocumentInfo ( 0 , 'author' , moment ( ) , 'message' , 'title' , [ 'main' ] , 'http://example.com' , 'test' )
96
102
await notification . notify ( [ documentInfo ] )
97
103
chai . expect ( ( transportStub as unknown as SinonStubbedInstance < Mail > ) . sendMail . notCalled ) . to . be . true
98
104
} )
99
105
it ( 'should not send notifications for an excluded document' , async ( ) : Promise < void > => {
100
106
const notification = new Notification ( configuration , '' , confluence , transportStub )
101
- const documentInfo = new DocumentInfo ( 0 , 'author2' , moment ( ) , 'message' , 'NOT' , [ 'main' , 'Test' ] , 'http://example.com' )
107
+ const documentInfo = new DocumentInfo ( 0 , 'author2' , moment ( ) , 'message' , 'NOT' , [ 'main' , 'Test' ] , 'http://example.com' , 'test' )
102
108
await notification . notify ( [ documentInfo ] )
103
109
chai . expect ( ( transportStub as unknown as SinonStubbedInstance < Mail > ) . sendMail . calledOnce ) . to . be . false
104
110
} )
105
111
106
112
it ( 'should send notifications in a batch if configured' , async ( ) : Promise < void > => {
107
113
const notification = new Notification ( configuration , '' , confluence , transportStub )
108
- const documentInfo = new DocumentInfo ( 0 , 'author' , moment ( ) , 'message' , 'title1' , [ 'main' ] , 'http://example.com' )
109
- const documentInfo2 = new DocumentInfo ( 0 , 'author' , moment ( ) , 'message' , 'title2' , [ 'main' ] , 'http://example.com' )
114
+ const documentInfo = new DocumentInfo ( 0 , 'author' , moment ( ) , 'message' , 'title1' , [ 'main' ] , 'http://example.com' , 'test' )
115
+ const documentInfo2 = new DocumentInfo ( 0 , 'author' , moment ( ) , 'message' , 'title2' , [ 'main' ] , 'http://example.com' , 'test' )
110
116
await notification . notify ( [ documentInfo , documentInfo2 ] )
111
117
chai . expect ( ( transportStub as unknown as SinonStubbedInstance < Mail > ) . sendMail . calledOnce ) . to . be . true
112
118
chai . expect (
113
119
( transportStub as unknown as SinonStubbedInstance < Mail > ) . sendMail . calledWith ( {
114
120
from :
'Notification <[email protected] >' ,
115
121
116
122
subject : Handlebars . compile ( MockServer . NOTIFICATION_SUBJECT ) ( {
123
+
117
124
documentsCount : 2 ,
118
125
documents : [ documentInfo , documentInfo2 ] ,
119
126
multipleDocuments : true ,
120
127
} ) ,
121
128
html : Handlebars . compile ( MockServer . NOTIFICATION_BODY ) ( {
129
+
122
130
documentsCount : 2 ,
123
131
documents : [ documentInfo , documentInfo2 ] ,
124
132
multipleDocuments : true ,
0 commit comments