@@ -8,8 +8,17 @@ const runBrowser = require("../helpers/run-browser");
8
8
const port = require ( "../ports-map" ) . bonjour ;
9
9
10
10
describe ( "bonjour option" , ( ) => {
11
- const mockPublish = jest . fn ( ) ;
12
- const mockUnpublishAll = jest . fn ( ) ;
11
+ let mockPublish ;
12
+ let mockUnpublishAll ;
13
+ let mockDestroy ;
14
+
15
+ beforeEach ( ( ) => {
16
+ mockPublish = jest . fn ( ) ;
17
+ mockUnpublishAll = jest . fn ( ( callback ) => {
18
+ callback ( ) ;
19
+ } ) ;
20
+ mockDestroy = jest . fn ( ) ;
21
+ } ) ;
13
22
14
23
describe ( "as true" , ( ) => {
15
24
let compiler ;
@@ -24,6 +33,7 @@ describe("bonjour option", () => {
24
33
return {
25
34
publish : mockPublish ,
26
35
unpublishAll : mockUnpublishAll ,
36
+ destroy : mockDestroy ,
27
37
} ;
28
38
} ) ;
29
39
@@ -42,8 +52,10 @@ describe("bonjour option", () => {
42
52
afterEach ( async ( ) => {
43
53
await browser . close ( ) ;
44
54
await server . stop ( ) ;
55
+
45
56
mockPublish . mockReset ( ) ;
46
57
mockUnpublishAll . mockReset ( ) ;
58
+ mockDestroy . mockReset ( ) ;
47
59
} ) ;
48
60
49
61
it ( "should call bonjour with correct params" , async ( ) => {
@@ -69,6 +81,7 @@ describe("bonjour option", () => {
69
81
} ) ;
70
82
71
83
expect ( mockUnpublishAll ) . toHaveBeenCalledTimes ( 0 ) ;
84
+ expect ( mockDestroy ) . toHaveBeenCalledTimes ( 0 ) ;
72
85
73
86
expect ( response . status ( ) ) . toMatchSnapshot ( "response status" ) ;
74
87
@@ -93,6 +106,7 @@ describe("bonjour option", () => {
93
106
return {
94
107
publish : mockPublish ,
95
108
unpublishAll : mockUnpublishAll ,
109
+ destroy : mockDestroy ,
96
110
} ;
97
111
} ) ;
98
112
@@ -111,8 +125,10 @@ describe("bonjour option", () => {
111
125
afterEach ( async ( ) => {
112
126
await browser . close ( ) ;
113
127
await server . stop ( ) ;
128
+
114
129
mockPublish . mockReset ( ) ;
115
130
mockUnpublishAll . mockReset ( ) ;
131
+ mockDestroy . mockReset ( ) ;
116
132
} ) ;
117
133
118
134
it ( "should call bonjour with 'https' type" , async ( ) => {
@@ -138,6 +154,7 @@ describe("bonjour option", () => {
138
154
} ) ;
139
155
140
156
expect ( mockUnpublishAll ) . toHaveBeenCalledTimes ( 0 ) ;
157
+ expect ( mockDestroy ) . toHaveBeenCalledTimes ( 0 ) ;
141
158
142
159
expect ( response . status ( ) ) . toMatchSnapshot ( "response status" ) ;
143
160
@@ -162,6 +179,7 @@ describe("bonjour option", () => {
162
179
return {
163
180
publish : mockPublish ,
164
181
unpublishAll : mockUnpublishAll ,
182
+ destroy : mockDestroy ,
165
183
} ;
166
184
} ) ;
167
185
@@ -180,8 +198,10 @@ describe("bonjour option", () => {
180
198
afterEach ( async ( ) => {
181
199
await browser . close ( ) ;
182
200
await server . stop ( ) ;
201
+
183
202
mockPublish . mockReset ( ) ;
184
203
mockUnpublishAll . mockReset ( ) ;
204
+ mockDestroy . mockReset ( ) ;
185
205
} ) ;
186
206
187
207
it ( "should call bonjour with 'https' type" , async ( ) => {
@@ -207,6 +227,7 @@ describe("bonjour option", () => {
207
227
} ) ;
208
228
209
229
expect ( mockUnpublishAll ) . toHaveBeenCalledTimes ( 0 ) ;
230
+ expect ( mockDestroy ) . toHaveBeenCalledTimes ( 0 ) ;
210
231
211
232
expect ( response . status ( ) ) . toMatchSnapshot ( "response status" ) ;
212
233
@@ -231,6 +252,7 @@ describe("bonjour option", () => {
231
252
return {
232
253
publish : mockPublish ,
233
254
unpublishAll : mockUnpublishAll ,
255
+ destroy : mockDestroy ,
234
256
} ;
235
257
} ) ;
236
258
@@ -258,8 +280,10 @@ describe("bonjour option", () => {
258
280
afterEach ( async ( ) => {
259
281
await browser . close ( ) ;
260
282
await server . stop ( ) ;
283
+
261
284
mockPublish . mockReset ( ) ;
262
285
mockUnpublishAll . mockReset ( ) ;
286
+ mockDestroy . mockReset ( ) ;
263
287
} ) ;
264
288
265
289
it ( "should apply bonjour options" , async ( ) => {
@@ -286,6 +310,7 @@ describe("bonjour option", () => {
286
310
} ) ;
287
311
288
312
expect ( mockUnpublishAll ) . toHaveBeenCalledTimes ( 0 ) ;
313
+ expect ( mockDestroy ) . toHaveBeenCalledTimes ( 0 ) ;
289
314
290
315
expect ( response . status ( ) ) . toMatchSnapshot ( "response status" ) ;
291
316
@@ -310,6 +335,7 @@ describe("bonjour option", () => {
310
335
return {
311
336
publish : mockPublish ,
312
337
unpublishAll : mockUnpublishAll ,
338
+ destroy : mockDestroy ,
313
339
} ;
314
340
} ) ;
315
341
@@ -338,8 +364,10 @@ describe("bonjour option", () => {
338
364
afterEach ( async ( ) => {
339
365
await browser . close ( ) ;
340
366
await server . stop ( ) ;
367
+
341
368
mockPublish . mockReset ( ) ;
342
369
mockUnpublishAll . mockReset ( ) ;
370
+ mockDestroy . mockReset ( ) ;
343
371
} ) ;
344
372
345
373
it ( "should apply bonjour options" , async ( ) => {
@@ -366,6 +394,7 @@ describe("bonjour option", () => {
366
394
} ) ;
367
395
368
396
expect ( mockUnpublishAll ) . toHaveBeenCalledTimes ( 0 ) ;
397
+ expect ( mockDestroy ) . toHaveBeenCalledTimes ( 0 ) ;
369
398
370
399
expect ( response . status ( ) ) . toMatchSnapshot ( "response status" ) ;
371
400
@@ -390,6 +419,7 @@ describe("bonjour option", () => {
390
419
return {
391
420
publish : mockPublish ,
392
421
unpublishAll : mockUnpublishAll ,
422
+ destroy : mockDestroy ,
393
423
} ;
394
424
} ) ;
395
425
@@ -402,7 +432,9 @@ describe("bonjour option", () => {
402
432
type : "http" ,
403
433
protocol : "udp" ,
404
434
} ,
405
- server : "https" ,
435
+ server : {
436
+ type : "https" ,
437
+ } ,
406
438
} ,
407
439
compiler
408
440
) ;
@@ -418,6 +450,7 @@ describe("bonjour option", () => {
418
450
afterEach ( async ( ) => {
419
451
await browser . close ( ) ;
420
452
await server . stop ( ) ;
453
+
421
454
mockPublish . mockReset ( ) ;
422
455
mockUnpublishAll . mockReset ( ) ;
423
456
} ) ;
@@ -446,6 +479,7 @@ describe("bonjour option", () => {
446
479
} ) ;
447
480
448
481
expect ( mockUnpublishAll ) . toHaveBeenCalledTimes ( 0 ) ;
482
+ expect ( mockDestroy ) . toHaveBeenCalledTimes ( 0 ) ;
449
483
450
484
expect ( response . status ( ) ) . toMatchSnapshot ( "response status" ) ;
451
485
0 commit comments