|
@@ -1,11 +1,11 @@
|
|
|
-import { describe, beforeEach, it, sinon, expect } from '../../../../../test/lib/common';
|
|
|
|
|
|
|
+jest.mock('app/core/core', () => ({}));
|
|
|
|
|
|
|
|
import $ from 'jquery';
|
|
import $ from 'jquery';
|
|
|
import GraphTooltip from '../graph_tooltip';
|
|
import GraphTooltip from '../graph_tooltip';
|
|
|
|
|
|
|
|
var scope = {
|
|
var scope = {
|
|
|
- appEvent: sinon.spy(),
|
|
|
|
|
- onAppEvent: sinon.spy(),
|
|
|
|
|
|
|
+ appEvent: jest.fn(),
|
|
|
|
|
+ onAppEvent: jest.fn(),
|
|
|
ctrl: {},
|
|
ctrl: {},
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -47,22 +47,22 @@ describe('findHoverIndexFromData', function() {
|
|
|
|
|
|
|
|
it('should return 0 if posX out of lower bounds', function() {
|
|
it('should return 0 if posX out of lower bounds', function() {
|
|
|
var posX = 99;
|
|
var posX = 99;
|
|
|
- expect(tooltip.findHoverIndexFromData(posX, series)).to.be(0);
|
|
|
|
|
|
|
+ expect(tooltip.findHoverIndexFromData(posX, series)).toBe(0);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('should return n - 1 if posX out of upper bounds', function() {
|
|
it('should return n - 1 if posX out of upper bounds', function() {
|
|
|
var posX = 108;
|
|
var posX = 108;
|
|
|
- expect(tooltip.findHoverIndexFromData(posX, series)).to.be(series.data.length - 1);
|
|
|
|
|
|
|
+ expect(tooltip.findHoverIndexFromData(posX, series)).toBe(series.data.length - 1);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('should return i if posX in series', function() {
|
|
it('should return i if posX in series', function() {
|
|
|
var posX = 104;
|
|
var posX = 104;
|
|
|
- expect(tooltip.findHoverIndexFromData(posX, series)).to.be(4);
|
|
|
|
|
|
|
+ expect(tooltip.findHoverIndexFromData(posX, series)).toBe(4);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('should return i if posX not in series and i + 1 > posX', function() {
|
|
it('should return i if posX not in series and i + 1 > posX', function() {
|
|
|
var posX = 104.9;
|
|
var posX = 104.9;
|
|
|
- expect(tooltip.findHoverIndexFromData(posX, series)).to.be(4);
|
|
|
|
|
|
|
+ expect(tooltip.findHoverIndexFromData(posX, series)).toBe(4);
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -73,17 +73,17 @@ describeSharedTooltip('steppedLine false, stack false', function(ctx) {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('should return 2 series', function() {
|
|
it('should return 2 series', function() {
|
|
|
- expect(ctx.results.length).to.be(2);
|
|
|
|
|
|
|
+ expect(ctx.results.length).toBe(2);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('should add time to results array', function() {
|
|
it('should add time to results array', function() {
|
|
|
- expect(ctx.results.time).to.be(10);
|
|
|
|
|
|
|
+ expect(ctx.results.time).toBe(10);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('should set value and hoverIndex', function() {
|
|
it('should set value and hoverIndex', function() {
|
|
|
- expect(ctx.results[0].value).to.be(15);
|
|
|
|
|
- expect(ctx.results[1].value).to.be(2);
|
|
|
|
|
- expect(ctx.results[0].hoverIndex).to.be(0);
|
|
|
|
|
|
|
+ expect(ctx.results[0].value).toBe(15);
|
|
|
|
|
+ expect(ctx.results[1].value).toBe(2);
|
|
|
|
|
+ expect(ctx.results[0].hoverIndex).toBe(0);
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -121,7 +121,7 @@ describeSharedTooltip('steppedLine false, stack true, individual false', functio
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('should show stacked value', function() {
|
|
it('should show stacked value', function() {
|
|
|
- expect(ctx.results[1].value).to.be(17);
|
|
|
|
|
|
|
+ expect(ctx.results[1].value).toBe(17);
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -152,7 +152,7 @@ describeSharedTooltip('steppedLine false, stack true, individual false, series s
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('should not show stacked value', function() {
|
|
it('should not show stacked value', function() {
|
|
|
- expect(ctx.results[1].value).to.be(2);
|
|
|
|
|
|
|
+ expect(ctx.results[1].value).toBe(2);
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -184,6 +184,6 @@ describeSharedTooltip('steppedLine false, stack true, individual true', function
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('should not show stacked value', function() {
|
|
it('should not show stacked value', function() {
|
|
|
- expect(ctx.results[1].value).to.be(2);
|
|
|
|
|
|
|
+ expect(ctx.results[1].value).toBe(2);
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|