From da9a28f37d37a13ba85618eacfb2f5117184303a Mon Sep 17 00:00:00 2001 From: Tobias Skarhed Date: Mon, 11 Jun 2018 15:59:20 +0200 Subject: [PATCH] Karma to Jest: graph-tooltip --- ...tooltip_specs.ts => graph_tooltip.jest.ts} | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) rename public/app/plugins/panel/graph/specs/{tooltip_specs.ts => graph_tooltip.jest.ts} (83%) diff --git a/public/app/plugins/panel/graph/specs/tooltip_specs.ts b/public/app/plugins/panel/graph/specs/graph_tooltip.jest.ts similarity index 83% rename from public/app/plugins/panel/graph/specs/tooltip_specs.ts rename to public/app/plugins/panel/graph/specs/graph_tooltip.jest.ts index 7dd5ed9b8a9..3bc60ed8ea3 100644 --- a/public/app/plugins/panel/graph/specs/tooltip_specs.ts +++ b/public/app/plugins/panel/graph/specs/graph_tooltip.jest.ts @@ -1,11 +1,11 @@ -import { describe, beforeEach, it, sinon, expect } from '../../../../../test/lib/common'; +jest.mock('app/core/core', () => ({})); import $ from 'jquery'; import GraphTooltip from '../graph_tooltip'; var scope = { - appEvent: sinon.spy(), - onAppEvent: sinon.spy(), + appEvent: jest.fn(), + onAppEvent: jest.fn(), ctrl: {}, }; @@ -47,22 +47,22 @@ describe('findHoverIndexFromData', function() { it('should return 0 if posX out of lower bounds', function() { 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() { 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() { 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() { 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() { - expect(ctx.results.length).to.be(2); + expect(ctx.results.length).toBe(2); }); 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() { - 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() { - 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() { - 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() { - expect(ctx.results[1].value).to.be(2); + expect(ctx.results[1].value).toBe(2); }); });