mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
fixed the over selection issue and added tests to make sure when a visualization is destroyed, it only destroys the charts in its own div
This commit is contained in:
parent
519168fe01
commit
54ca084475
2 changed files with 10 additions and 2 deletions
|
@ -100,7 +100,7 @@ define(function (require) {
|
|||
* @method destroy
|
||||
*/
|
||||
Vis.prototype.destroy = function () {
|
||||
var selection = d3.select('.vis-wrapper');
|
||||
var selection = d3.select(this.el).select('.vis-wrapper');
|
||||
|
||||
this.resizeChecker.off('resize', this.resize);
|
||||
this.resizeChecker.destroy();
|
||||
|
|
|
@ -27,6 +27,7 @@ define(function (require) {
|
|||
var beforeEvent = 'click';
|
||||
var afterEvent = 'brush';
|
||||
var vis;
|
||||
var secondVis;
|
||||
var numberOfCharts;
|
||||
|
||||
beforeEach(function () {
|
||||
|
@ -36,12 +37,14 @@ define(function (require) {
|
|||
beforeEach(function () {
|
||||
inject(function (d3, Private) {
|
||||
vis = Private(require('vislib_fixtures/_vis_fixture'))();
|
||||
secondVis = Private(require('vislib_fixtures/_vis_fixture'))();
|
||||
require('css!components/vislib/styles/main');
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
$(vis.el).remove();
|
||||
$(secondVis.el).remove();
|
||||
vis = null;
|
||||
});
|
||||
|
||||
|
@ -86,11 +89,16 @@ define(function (require) {
|
|||
|
||||
describe('destroy Method', function () {
|
||||
beforeEach(function () {
|
||||
secondVis.render(data);
|
||||
vis.destroy();
|
||||
});
|
||||
|
||||
it('should remove all DOM elements from el', function () {
|
||||
expect($('.vis-wrapper').length).to.be(0);
|
||||
expect($(vis.el).find('.vis-wrapper').length).to.be(0);
|
||||
});
|
||||
|
||||
it('should not remove visualizations that have not been destroyed', function () {
|
||||
expect($(secondVis.el).find('.vis-wrapper').length).to.be(1);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue