@@ -483,7 +483,6 @@ function(test) {
483
483
var discovery = {
484
484
endpointToHash : sinon . stub ( ) . returns ( hash ) ,
485
485
pickBalancer : sinon . stub ( ) . returns ( balancer ) ,
486
- pickEndpoint : sinon . stub ( ) . returns ( endpoint ) ,
487
486
} ;
488
487
489
488
var cookies = {
@@ -504,7 +503,47 @@ function(test) {
504
503
505
504
test . isTrue ( discovery . endpointToHash . calledWith ( endpoint ) ) ;
506
505
var info = JSON . parse ( res . end . firstCall . args [ 0 ] ) ;
507
- test . equal ( info . base_url , format ( "epoint/cluster-ddp/%s/web" , hash ) ) ;
506
+ test . equal ( info . base_url , format ( endpoint + "/cluster-ddp/%s/web" , hash ) ) ;
507
+ test . equal ( info . websocket , true ) ;
508
+
509
+ balancerMock . verify ( ) ;
510
+ balancerMock . restore ( ) ;
511
+ } ) ;
512
+ } ) ;
513
+ } ) ;
514
+
515
+ Tinytest . add (
516
+ 'Balancer - _sendSockJsInfo - correct base_url, web, with no balancer, endpoint has sub path' ,
517
+ function ( test ) {
518
+ var balancer = null ;
519
+ // endpoint has a sub path
520
+ var endpoint = "http://localhost:8001/private" ;
521
+ var hash = "hashhh" ;
522
+ var uiService = "web" ;
523
+ var discovery = {
524
+ endpointToHash : sinon . stub ( ) . returns ( hash ) ,
525
+ pickBalancer : sinon . stub ( ) . returns ( balancer ) ,
526
+ } ;
527
+
528
+ var cookies = {
529
+ get : sinon . stub ( ) . returns ( hash )
530
+ } ;
531
+
532
+ var balancerMock = sinon . mock ( Balancer ) ;
533
+ balancerMock . expects ( '_pickJustEndpoint' )
534
+ . withArgs ( hash , "web" )
535
+ . returns ( endpoint ) ;
536
+
537
+ var req = { url : "/web/sockjs/info" } ;
538
+ var res = { writeHead : sinon . stub ( ) , end : sinon . stub ( ) } ;
539
+
540
+ WithCluster ( { _uiService : uiService } , function ( ) {
541
+ WithDiscovery ( discovery , function ( ) {
542
+ Balancer . _sendSockJsInfo ( req , res , cookies ) ;
543
+
544
+ test . isTrue ( discovery . endpointToHash . calledWith ( endpoint ) ) ;
545
+ var info = JSON . parse ( res . end . firstCall . args [ 0 ] ) ;
546
+ test . equal ( info . base_url , format ( endpoint + "/cluster-ddp/%s/web" , hash ) ) ;
508
547
test . equal ( info . websocket , true ) ;
509
548
510
549
balancerMock . verify ( ) ;
0 commit comments