Skip to content

Commit 79f93b9

Browse files
committed
improve plotlyServerUrl test
1 parent cacc76b commit 79f93b9

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/jasmine/tests/config_test.js

+30
Original file line numberDiff line numberDiff line change
@@ -474,9 +474,13 @@ describe('config argument', function() {
474474

475475
describe('plotlyServerUrl:', function() {
476476
var gd;
477+
var form;
477478

478479
beforeEach(function() {
479480
gd = createGraphDiv();
481+
spyOn(HTMLFormElement.prototype, 'submit').and.callFake(function() {
482+
form = this;
483+
});
480484
});
481485

482486
afterEach(destroyGraphDiv);
@@ -485,6 +489,10 @@ describe('config argument', function() {
485489
Plotly.plot(gd, [], {})
486490
.then(function() {
487491
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');
488496
})
489497
.catch(failTest)
490498
.then(done);
@@ -494,9 +502,31 @@ describe('config argument', function() {
494502
Plotly.plot(gd, [], {}, {plotlyServerUrl: 'dummy'})
495503
.then(function() {
496504
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');
497509
})
498510
.catch(failTest)
499511
.then(done);
500512
});
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+
});
501531
});
502532
});

0 commit comments

Comments
 (0)