@@ -27,4 +27,55 @@ describe("E2E `port` option", function () {
2727 done ( ) ;
2828 } ) ;
2929 } ) ;
30+ it ( "sets extra port option for socket in proxy mode" , function ( done ) {
31+ browserSync . reset ( ) ;
32+
33+ var stub = sinon . stub ( utils , "getPort" ) ;
34+
35+ stub . onCall ( 0 ) . yields ( null , 3000 ) ;
36+ stub . onCall ( 1 ) . yields ( null , 3001 ) ;
37+
38+ var config = {
39+ logLevel : "silent" ,
40+ proxy : "localhost" ,
41+ online : false ,
42+ open : false
43+ } ;
44+
45+ browserSync ( config , function ( err , bs ) {
46+ bs . cleanup ( ) ;
47+ assert . equal ( bs . options . get ( "port" ) , 3000 ) ;
48+ assert . equal ( stub . getCall ( 1 ) . args [ 0 ] , 3001 ) ;
49+ assert . equal ( bs . options . getIn ( [ "socket" , "port" ] ) , 3001 ) ;
50+ utils . getPort . restore ( ) ;
51+ done ( ) ;
52+ } ) ;
53+ } ) ;
54+ it ( "uses user-given extra port option for socket in proxy mode" , function ( done ) {
55+ browserSync . reset ( ) ;
56+
57+ var stub = sinon . stub ( utils , "getPort" ) ;
58+
59+ stub . onCall ( 0 ) . yields ( null , 3000 ) ;
60+ stub . onCall ( 1 ) . yields ( null , 8001 ) ;
61+
62+ var config = {
63+ logLevel : "silent" ,
64+ proxy : "localhost" ,
65+ socket : {
66+ port : 8001
67+ } ,
68+ online : false ,
69+ open : false
70+ } ;
71+
72+ browserSync ( config , function ( err , bs ) {
73+ bs . cleanup ( ) ;
74+ assert . equal ( bs . options . get ( "port" ) , 3000 ) ;
75+ assert . equal ( stub . getCall ( 1 ) . args [ 0 ] , 8001 ) ;
76+ assert . equal ( bs . options . getIn ( [ "socket" , "port" ] ) , 8001 ) ;
77+ utils . getPort . restore ( ) ;
78+ done ( ) ;
79+ } ) ;
80+ } ) ;
3081} ) ;
0 commit comments