@@ -19,31 +19,97 @@ describe('bonjour option', () => {
19
19
} ) ;
20
20
} ) ;
21
21
22
- beforeEach ( ( done ) => {
23
- server = testServer . start (
24
- config ,
25
- {
26
- bonjour : true ,
22
+ afterEach ( ( ) => {
23
+ mockPublish . mockReset ( ) ;
24
+ mockUnpublishAll . mockReset ( ) ;
25
+ } ) ;
26
+
27
+ describe ( 'http' , ( ) => {
28
+ beforeEach ( ( done ) => {
29
+ server = testServer . start (
30
+ config ,
31
+ {
32
+ bonjour : true ,
33
+ port,
34
+ } ,
35
+ done
36
+ ) ;
37
+ } ) ;
38
+
39
+ afterEach ( ( done ) => {
40
+ server . close ( done ) ;
41
+ } ) ;
42
+
43
+ it ( 'should call bonjour with correct params' , ( ) => {
44
+ expect ( mockPublish ) . toHaveBeenCalledTimes ( 1 ) ;
45
+ expect ( mockPublish ) . toHaveBeenCalledWith ( {
46
+ name : `Webpack Dev Server ${ os . hostname ( ) } :${ port } ` ,
27
47
port,
28
- } ,
29
- done
30
- ) ;
48
+ type : 'http' ,
49
+ subtypes : [ 'webpack' ] ,
50
+ } ) ;
51
+ expect ( mockUnpublishAll ) . toHaveBeenCalledTimes ( 0 ) ;
52
+ } ) ;
31
53
} ) ;
32
54
33
- afterEach ( ( done ) => {
34
- mockPublish . mockReset ( ) ;
35
- mockUnpublishAll . mockReset ( ) ;
36
- server . close ( done ) ;
55
+ describe ( 'https option' , ( ) => {
56
+ beforeEach ( ( done ) => {
57
+ server = testServer . start (
58
+ config ,
59
+ {
60
+ bonjour : true ,
61
+ port,
62
+ https : true ,
63
+ } ,
64
+ done
65
+ ) ;
66
+ } ) ;
67
+
68
+ afterEach ( ( done ) => {
69
+ server . close ( done ) ;
70
+ } ) ;
71
+
72
+ it ( 'bonjour should use https when passed in option' , ( ) => {
73
+ expect ( mockPublish ) . toHaveBeenCalledTimes ( 1 ) ;
74
+ expect ( mockPublish ) . toHaveBeenCalledWith ( {
75
+ name : `Webpack Dev Server ${ os . hostname ( ) } :${ port } ` ,
76
+ port,
77
+ type : 'https' ,
78
+ subtypes : [ 'webpack' ] ,
79
+ } ) ;
80
+ expect ( mockUnpublishAll ) . toHaveBeenCalledTimes ( 0 ) ;
81
+ } ) ;
37
82
} ) ;
38
83
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' ] ,
84
+ describe ( 'bonjour object' , ( ) => {
85
+ beforeEach ( ( done ) => {
86
+ server = testServer . start (
87
+ config ,
88
+ {
89
+ bonjour : {
90
+ type : 'https' ,
91
+ protocol : 'udp' ,
92
+ } ,
93
+ port,
94
+ } ,
95
+ done
96
+ ) ;
97
+ } ) ;
98
+
99
+ afterEach ( ( done ) => {
100
+ server . close ( done ) ;
101
+ } ) ;
102
+
103
+ it ( 'applies bonjour options' , ( ) => {
104
+ expect ( mockPublish ) . toHaveBeenCalledTimes ( 1 ) ;
105
+ expect ( mockPublish ) . toHaveBeenCalledWith ( {
106
+ name : `Webpack Dev Server ${ os . hostname ( ) } :${ port } ` ,
107
+ port,
108
+ type : 'https' ,
109
+ protocol : 'udp' ,
110
+ subtypes : [ 'webpack' ] ,
111
+ } ) ;
112
+ expect ( mockUnpublishAll ) . toHaveBeenCalledTimes ( 0 ) ;
46
113
} ) ;
47
- expect ( mockUnpublishAll ) . toHaveBeenCalledTimes ( 0 ) ;
48
114
} ) ;
49
115
} ) ;
0 commit comments