@@ -95,6 +95,12 @@ describe('module/serviceListener', function() {
9595 } ) ;
9696
9797 describe ( 'without a service' , function ( ) {
98+ beforeEach ( function ( ) {
99+ config . set ( {
100+ services : [ ]
101+ } ) ;
102+ } ) ;
103+
98104 it ( 'should resolve' , function ( ) {
99105 return assert . isFulfilled ( serviceListener . _setBuildStatus ( {
100106 project : 'project' ,
@@ -107,29 +113,56 @@ describe('module/serviceListener', function() {
107113 describe ( 'with a service' , function ( ) {
108114 beforeEach ( function ( ) {
109115 config . set ( {
110- service : fakeService
116+ services : [ fakeService ]
111117 } ) ;
112118 } ) ;
113119
114- it ( 'should call the service setBuildStatus ', function ( ) {
115- storageStub . getProjectInfo = this . sinon . stub ( ) . resolves ( {
116- service : projectConfig
120+ describe ( 'that does not match the project config ', function ( ) {
121+ beforeEach ( function ( ) {
122+ fakeService . serviceKey = 'foo' ;
117123 } ) ;
118124
119- return serviceListener . _setBuildStatus ( {
120- project : 'project' ,
121- sha : 'sha' ,
122- status : 'success'
123- } )
124- . then ( function ( ) {
125- assert . calledWithExactly (
126- fakeService . setBuildStatus ,
127- projectConfig ,
128- {
129- sha : 'sha' ,
130- status : 'success'
131- }
132- ) ;
125+ it ( 'should not call service setBuildStatus' , function ( ) {
126+ storageStub . getProjectInfo = this . sinon . stub ( ) . resolves ( {
127+ service : projectConfig
128+ } ) ;
129+
130+ return serviceListener . _setBuildStatus ( {
131+ project : 'project' ,
132+ sha : 'sha' ,
133+ status : 'success'
134+ } )
135+ . then ( function ( ) {
136+ assert . notCalled ( fakeService . setBuildStatus ) ;
137+ } ) ;
138+ } ) ;
139+ } ) ;
140+
141+ describe ( 'that matches the project config' , function ( ) {
142+ beforeEach ( function ( ) {
143+ fakeService . serviceKey = 'github' ;
144+ } ) ;
145+
146+ it ( 'should call the service setBuildStatus' , function ( ) {
147+ storageStub . getProjectInfo = this . sinon . stub ( ) . resolves ( {
148+ service : projectConfig
149+ } ) ;
150+
151+ return serviceListener . _setBuildStatus ( {
152+ project : 'project' ,
153+ sha : 'sha' ,
154+ status : 'success'
155+ } )
156+ . then ( function ( ) {
157+ assert . calledWithExactly (
158+ fakeService . setBuildStatus ,
159+ projectConfig ,
160+ {
161+ sha : 'sha' ,
162+ status : 'success'
163+ }
164+ ) ;
165+ } ) ;
133166 } ) ;
134167 } ) ;
135168 } ) ;
@@ -166,6 +199,12 @@ describe('module/serviceListener', function() {
166199 } ) ;
167200
168201 describe ( 'without a service' , function ( ) {
202+ beforeEach ( function ( ) {
203+ config . set ( {
204+ services : [ ]
205+ } ) ;
206+ } ) ;
207+
169208 it ( 'should resolve' , function ( ) {
170209 return assert . isFulfilled ( serviceListener . _addComment ( {
171210 project : 'project' ,
@@ -178,29 +217,56 @@ describe('module/serviceListener', function() {
178217 describe ( 'with a service' , function ( ) {
179218 beforeEach ( function ( ) {
180219 config . set ( {
181- service : fakeService
220+ services : [ fakeService ]
182221 } ) ;
183222 } ) ;
184223
185- it ( 'should call the service addComment ', function ( ) {
186- storageStub . getProjectInfo = this . sinon . stub ( ) . resolves ( {
187- service : projectConfig
224+ describe ( 'that does not match the project config ', function ( ) {
225+ beforeEach ( function ( ) {
226+ fakeService . serviceKey = 'foo' ;
188227 } ) ;
189228
190- return serviceListener . _addComment ( {
191- project : 'project' ,
192- sha : 'sha' ,
193- comment : 'comment'
194- } )
195- . then ( function ( ) {
196- assert . calledWithExactly (
197- fakeService . addComment ,
198- projectConfig ,
199- {
200- sha : 'sha' ,
201- comment : 'comment'
202- }
203- ) ;
229+ it ( 'should not call addComment' , function ( ) {
230+ storageStub . getProjectInfo = this . sinon . stub ( ) . resolves ( {
231+ service : projectConfig
232+ } ) ;
233+
234+ return serviceListener . _addComment ( {
235+ project : 'project' ,
236+ sha : 'sha' ,
237+ comment : 'comment'
238+ } )
239+ . then ( function ( ) {
240+ assert . notCalled ( fakeService . addComment ) ;
241+ } ) ;
242+ } ) ;
243+ } ) ;
244+
245+ describe ( 'that matches the project config' , function ( ) {
246+ beforeEach ( function ( ) {
247+ fakeService . serviceKey = 'github' ;
248+ } ) ;
249+
250+ it ( 'should call the service addComment' , function ( ) {
251+ storageStub . getProjectInfo = this . sinon . stub ( ) . resolves ( {
252+ service : projectConfig
253+ } ) ;
254+
255+ return serviceListener . _addComment ( {
256+ project : 'project' ,
257+ sha : 'sha' ,
258+ comment : 'comment'
259+ } )
260+ . then ( function ( ) {
261+ assert . calledWithExactly (
262+ fakeService . addComment ,
263+ projectConfig ,
264+ {
265+ sha : 'sha' ,
266+ comment : 'comment'
267+ }
268+ ) ;
269+ } ) ;
204270 } ) ;
205271 } ) ;
206272 } ) ;
0 commit comments