Skip to content

Commit f28e96a

Browse files
committed
extend plot_promise_test for resize
1 parent 805e0db commit f28e96a

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

test/jasmine/tests/plot_promise_test.js

+20-2
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,8 @@ describe('Plotly.___ methods', function() {
461461
Plotly.plot(initialDiv, data, {}).then(done);
462462
});
463463

464+
afterEach(destroyGraphDiv);
465+
464466
it('should return a resolved promise of the gd', function(done) {
465467
Plotly.Plots.resize(initialDiv).then(function(gd) {
466468
expect(gd).toBeDefined();
@@ -469,14 +471,30 @@ describe('Plotly.___ methods', function() {
469471
}).then(done);
470472
});
471473

472-
it('should return a rejected promise with no argument', function(done) {
473-
Plotly.Plots.resize().then(function() {
474+
it('should return a rejected promise if gd is hidden', function(done) {
475+
initialDiv.style.display = 'none';
476+
Plotly.Plots.resize(initialDiv).then(function() {
477+
expect(1).toBe(0, 'We were supposed to get an error.');
478+
}, function(err) {
479+
expect(err).toBeDefined();
480+
expect(err.message).toBe('Resize must be passed a displayed plot div element.');
481+
}).then(done);
482+
});
483+
484+
it('should return a rejected promise if gd is detached from the DOM', function(done) {
485+
destroyGraphDiv();
486+
Plotly.Plots.resize(initialDiv).then(function() {
474487
expect(1).toBe(0, 'We were supposed to get an error.');
475488
}, function(err) {
476489
expect(err).toBeDefined();
477490
expect(err.message).toBe('Resize must be passed a displayed plot div element.');
478491
}).then(done);
479492
});
493+
494+
it('errors before even generating a promise if gd is not defined', function() {
495+
expect(function() { Plotly.Plots.resize(); })
496+
.toThrow(new Error('DOM element provided is null or undefined'));
497+
});
480498
});
481499

482500
});

0 commit comments

Comments
 (0)