File tree Expand file tree Collapse file tree 3 files changed +50
-49
lines changed Expand file tree Collapse file tree 3 files changed +50
-49
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ const portsList = {
45
45
ModuleFederation : 1 ,
46
46
'setupExitSignals-option' : 1 ,
47
47
'watchFiles-option' : 1 ,
48
+ bonjour : 1 ,
48
49
} ;
49
50
50
51
let startPort = 8089 ;
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ const os = require ( 'os' ) ;
4
+ const config = require ( '../fixtures/simple-config/webpack.config' ) ;
5
+ const testServer = require ( '../helpers/test-server' ) ;
6
+ const port = require ( '../ports-map' ) . bonjour ;
7
+
8
+ describe ( 'bonjour option' , ( ) => {
9
+ let server ;
10
+ const mockPublish = jest . fn ( ) ;
11
+ const mockUnpublishAll = jest . fn ( ) ;
12
+
13
+ beforeAll ( ( ) => {
14
+ jest . mock ( 'bonjour' , ( ) => ( ) => {
15
+ return {
16
+ publish : mockPublish ,
17
+ unpublishAll : mockUnpublishAll ,
18
+ } ;
19
+ } ) ;
20
+ } ) ;
21
+
22
+ beforeEach ( ( done ) => {
23
+ server = testServer . start (
24
+ config ,
25
+ {
26
+ bonjour : true ,
27
+ port,
28
+ } ,
29
+ done
30
+ ) ;
31
+ } ) ;
32
+
33
+ afterEach ( ( done ) => {
34
+ mockPublish . mockReset ( ) ;
35
+ mockUnpublishAll . mockReset ( ) ;
36
+ server . close ( done ) ;
37
+ } ) ;
38
+
39
+ it ( 'should call bonjour with correct params' , ( ) => {
40
+ expect ( mockPublish ) . toHaveBeenCalledTimes ( 1 ) ;
41
+ expect ( mockPublish ) . toHaveBeenCalledWith ( {
42
+ name : `Webpack Dev Server ${ os . hostname ( ) } :${ port } ` ,
43
+ port,
44
+ type : 'http' ,
45
+ subtypes : [ 'webpack' ] ,
46
+ } ) ;
47
+ expect ( mockUnpublishAll ) . toHaveBeenCalledTimes ( 0 ) ;
48
+ } ) ;
49
+ } ) ;
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments