mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Mock things
This commit is contained in:
parent
a79c43420a
commit
2e2de38b31
@ -456,7 +456,6 @@ export class Link {
|
|||||||
this.chartHeight = this.height - this.margin.top - this.margin.bottom;
|
this.chartHeight = this.height - this.margin.top - this.margin.bottom;
|
||||||
this.chartTop = this.margin.top;
|
this.chartTop = this.margin.top;
|
||||||
this.chartBottom = this.chartTop + this.chartHeight;
|
this.chartBottom = this.chartTop + this.chartHeight;
|
||||||
|
|
||||||
if (this.panel.dataFormat === 'tsbuckets') {
|
if (this.panel.dataFormat === 'tsbuckets') {
|
||||||
this.addYAxisFromBuckets();
|
this.addYAxisFromBuckets();
|
||||||
} else {
|
} else {
|
||||||
@ -550,6 +549,7 @@ export class Link {
|
|||||||
.style('opacity', this.getCardOpacity.bind(this));
|
.style('opacity', this.getCardOpacity.bind(this));
|
||||||
|
|
||||||
let $cards = this.$heatmap.find('.heatmap-card');
|
let $cards = this.$heatmap.find('.heatmap-card');
|
||||||
|
console.log($cards);
|
||||||
$cards
|
$cards
|
||||||
.on('mouseenter', event => {
|
.on('mouseenter', event => {
|
||||||
this.tooltip.mouseOverBucket = true;
|
this.tooltip.mouseOverBucket = true;
|
||||||
|
@ -8,17 +8,24 @@ import TimeSeries from 'app/core/time_series2';
|
|||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
// import { Emitter } from 'app/core/core';
|
// import { Emitter } from 'app/core/core';
|
||||||
import rendering from '../rendering';
|
import rendering from '../rendering';
|
||||||
|
// import * as d3 from 'd3';
|
||||||
import { convertToHeatMap, convertToCards, histogramToHeatmap, calculateBucketSize } from '../heatmap_data_converter';
|
import { convertToHeatMap, convertToCards, histogramToHeatmap, calculateBucketSize } from '../heatmap_data_converter';
|
||||||
jest.mock('app/core/core', () => ({
|
jest.mock('app/core/core', () => ({
|
||||||
appEvents: {
|
appEvents: {
|
||||||
on: () => {},
|
on: () => {},
|
||||||
},
|
},
|
||||||
|
contextSrv: {
|
||||||
|
user: {
|
||||||
|
lightTheme: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('grafanaHeatmap', function() {
|
describe('grafanaHeatmap', function() {
|
||||||
// beforeEach(angularMocks.module('grafana.core'));
|
// beforeEach(angularMocks.module('grafana.core'));
|
||||||
|
|
||||||
let scope = <any>{};
|
let scope = <any>{};
|
||||||
|
let render;
|
||||||
|
|
||||||
function heatmapScenario(desc, func, elementWidth = 500) {
|
function heatmapScenario(desc, func, elementWidth = 500) {
|
||||||
describe(desc, function() {
|
describe(desc, function() {
|
||||||
@ -154,11 +161,20 @@ describe('grafanaHeatmap', function() {
|
|||||||
|
|
||||||
ctrl.data = ctx.data;
|
ctrl.data = ctx.data;
|
||||||
ctx.element = {
|
ctx.element = {
|
||||||
find: () => ({ on: () => {} }),
|
find: () => ({
|
||||||
|
on: () => {},
|
||||||
|
css: () => 189,
|
||||||
|
width: () => 189,
|
||||||
|
height: () => 200,
|
||||||
|
find: () => ({
|
||||||
|
on: () => {},
|
||||||
|
}),
|
||||||
|
}),
|
||||||
on: () => {},
|
on: () => {},
|
||||||
};
|
};
|
||||||
rendering(scope, ctx.element, [], ctrl);
|
render = rendering(scope, ctx.element, [], ctrl);
|
||||||
ctrl.events.emit('render');
|
render.render();
|
||||||
|
render.ctrl.renderingCompleted();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -172,6 +188,9 @@ describe('grafanaHeatmap', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should draw correct Y axis', function() {
|
it('should draw correct Y axis', function() {
|
||||||
|
console.log('Runnign first test');
|
||||||
|
// console.log(render.ctrl.data);
|
||||||
|
console.log(render.scope.yScale);
|
||||||
var yTicks = getTicks(ctx.element, '.axis-y');
|
var yTicks = getTicks(ctx.element, '.axis-y');
|
||||||
expect(yTicks).toEqual(['1', '2', '3']);
|
expect(yTicks).toEqual(['1', '2', '3']);
|
||||||
});
|
});
|
||||||
@ -317,13 +336,13 @@ describe('grafanaHeatmap', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function getTicks(element, axisSelector) {
|
function getTicks(element, axisSelector) {
|
||||||
return element
|
// return element
|
||||||
.find(axisSelector)
|
// .find(axisSelector)
|
||||||
.find('text')
|
// .find('text')
|
||||||
.map(function() {
|
// .map(function() {
|
||||||
return this.textContent;
|
// return this.textContent;
|
||||||
})
|
// })
|
||||||
.get();
|
// .get();
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatTime(timeStr) {
|
function formatTime(timeStr) {
|
||||||
|
Loading…
Reference in New Issue
Block a user