@@ -470,7 +470,63 @@ describe('config argument', function() {
470470 var editBox = document . getElementsByClassName ( 'plugin-editable editable' ) [ 0 ] ;
471471 expect ( editBox ) . toBeUndefined ( ) ;
472472 } ) ;
473+ } ) ;
474+
475+ describe ( 'plotlyServerURL:' , function ( ) {
476+ var gd ;
477+ var form ;
478+
479+ beforeEach ( function ( ) {
480+ gd = createGraphDiv ( ) ;
481+ spyOn ( HTMLFormElement . prototype , 'submit' ) . and . callFake ( function ( ) {
482+ form = this ;
483+ } ) ;
484+ } ) ;
473485
486+ afterEach ( destroyGraphDiv ) ;
487+
488+ it ( 'should default to plotly cloud' , function ( done ) {
489+ Plotly . plot ( gd , [ ] , { } )
490+ . then ( function ( ) {
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' ) ;
496+ } )
497+ . catch ( failTest )
498+ . then ( done ) ;
499+ } ) ;
474500
501+ it ( 'can be set to other base urls' , function ( done ) {
502+ Plotly . plot ( gd , [ ] , { } , { plotlyServerURL : 'dummy' } )
503+ . then ( function ( ) {
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' ) ;
509+ } )
510+ . catch ( failTest )
511+ . then ( done ) ;
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+ } ) ;
475531 } ) ;
476532} ) ;
0 commit comments