@@ -474,9 +474,13 @@ describe('config argument', function() {
474
474
475
475
describe ( 'plotlyServerUrl:' , function ( ) {
476
476
var gd ;
477
+ var form ;
477
478
478
479
beforeEach ( function ( ) {
479
480
gd = createGraphDiv ( ) ;
481
+ spyOn ( HTMLFormElement . prototype , 'submit' ) . and . callFake ( function ( ) {
482
+ form = this ;
483
+ } ) ;
480
484
} ) ;
481
485
482
486
afterEach ( destroyGraphDiv ) ;
@@ -485,6 +489,10 @@ describe('config argument', function() {
485
489
Plotly . plot ( gd , [ ] , { } )
486
490
. then ( function ( ) {
487
491
expect ( gd . _context . plotlyServerUrl ) . toBe ( 'https://plot.ly' ) ;
492
+
493
+ Plotly . Plots . sendDataToCloud ( gd ) ;
494
+ expect ( form . action ) . toBe ( 'https://plot.ly/external' ) ;
495
+ expect ( form . method ) . toBe ( 'post' ) ;
488
496
} )
489
497
. catch ( failTest )
490
498
. then ( done ) ;
@@ -494,9 +502,31 @@ describe('config argument', function() {
494
502
Plotly . plot ( gd , [ ] , { } , { plotlyServerUrl : 'dummy' } )
495
503
. then ( function ( ) {
496
504
expect ( gd . _context . plotlyServerUrl ) . toBe ( 'dummy' ) ;
505
+
506
+ Plotly . Plots . sendDataToCloud ( gd ) ;
507
+ expect ( form . action ) . toContain ( '/dummy/external' ) ;
508
+ expect ( form . method ) . toBe ( 'post' ) ;
497
509
} )
498
510
. catch ( failTest )
499
511
. then ( done ) ;
500
512
} ) ;
513
+
514
+ it ( 'has lesser priotiy then window env' , function ( done ) {
515
+ window . PLOTLYENV = { BASE_URL : 'yo' } ;
516
+
517
+ Plotly . plot ( gd , [ ] , { } , { plotlyServerUrl : 'dummy' } )
518
+ . then ( function ( ) {
519
+ expect ( gd . _context . plotlyServerUrl ) . toBe ( 'dummy' ) ;
520
+
521
+ Plotly . Plots . sendDataToCloud ( gd ) ;
522
+ expect ( form . action ) . toContain ( '/yo/external' ) ;
523
+ expect ( form . method ) . toBe ( 'post' ) ;
524
+ } )
525
+ . catch ( failTest )
526
+ . then ( function ( ) {
527
+ delete window . PLOTLY_ENV ;
528
+ done ( ) ;
529
+ } ) ;
530
+ } ) ;
501
531
} ) ;
502
532
} ) ;
0 commit comments