var specHelper = require('../../spec-helper'); var TimeSeriesContentView = require('../../../../../javascripts/deep-insights/widgets/time-series/content-view'); var WidgetModel = require('../../../../../javascripts/deep-insights/widgets/widget-model'); var HistogramChartView = require('../../../../../javascripts/deep-insights/widgets/histogram/chart'); describe('widgets/time-series/content-view', function () { var widgetModel, layerModel, dataviewModel, originalData; var nodeId = 'a0'; var createViewFn = function (options) { var vis = specHelper.createDefaultVis(); var source = vis.analysis.findNodeById(nodeId); layerModel = vis.map.layers.first(); dataviewModel = vis.dataviews.createHistogramModel({ column: 'col', source: source }); spyOn(dataviewModel, 'fetch').and.callThrough(); originalData = dataviewModel.getUnfilteredDataModel(); originalData.set({ data: [{ bin: 10 }, { bin: 3 }], start: 0, end: 256, bins: 2 }); widgetModel = new WidgetModel({ show_source: false }, { dataviewModel: dataviewModel, layerModel: layerModel }); spyOn(HistogramChartView.prototype, '_setupFillColor').and.returnValue('red'); var view = new TimeSeriesContentView({ model: widgetModel }); return view; }; describe('when widget has data', function () { describe('.render', function () { it('should render properly', function () { this.view = createViewFn(); this.view.render(); expect(this.view.$('.js-header').length).toBe(1); expect(this.view.$('.js-title').length).toBe(1); expect(this.view.$('.js-content').length).toBe(1); expect(this.view.$('.CDB-Widget-info').length).toBe(0); expect(this.view._histogramView).toBeDefined(); expect(this.view._headerView).toBeDefined(); expect(this.view._dropdownView).toBeDefined(); expect(this.view.render().$el.html()).toContain('