From 26f709e87ea5d551b46f3b15909165aee732e298 Mon Sep 17 00:00:00 2001 From: Tobias Skarhed Date: Fri, 27 Jul 2018 16:45:03 +0200 Subject: [PATCH 1/2] Karm to Jest --- ...map_ctrl_specs.ts => heatmap_ctrl.jest.ts} | 44 ++++++++++--------- 1 file changed, 24 insertions(+), 20 deletions(-) rename public/app/plugins/panel/heatmap/specs/{heatmap_ctrl_specs.ts => heatmap_ctrl.jest.ts} (61%) diff --git a/public/app/plugins/panel/heatmap/specs/heatmap_ctrl_specs.ts b/public/app/plugins/panel/heatmap/specs/heatmap_ctrl.jest.ts similarity index 61% rename from public/app/plugins/panel/heatmap/specs/heatmap_ctrl_specs.ts rename to public/app/plugins/panel/heatmap/specs/heatmap_ctrl.jest.ts index 98055ccf52d..70449763856 100644 --- a/public/app/plugins/panel/heatmap/specs/heatmap_ctrl_specs.ts +++ b/public/app/plugins/panel/heatmap/specs/heatmap_ctrl.jest.ts @@ -1,26 +1,30 @@ -import { describe, beforeEach, it, expect, angularMocks } from '../../../../../test/lib/common'; - import moment from 'moment'; import { HeatmapCtrl } from '../heatmap_ctrl'; -import helpers from '../../../../../test/specs/helpers'; describe('HeatmapCtrl', function() { - var ctx = new helpers.ControllerTestContext(); + let ctx = {}; - beforeEach(angularMocks.module('grafana.services')); - beforeEach(angularMocks.module('grafana.controllers')); - beforeEach( - angularMocks.module(function($compileProvider) { - $compileProvider.preAssignBindingsEnabled(true); - }) - ); + let $injector = { + get: () => {} + }; - beforeEach(ctx.providePhase()); - beforeEach(ctx.createPanelController(HeatmapCtrl)); - beforeEach(() => { - ctx.ctrl.annotationsPromise = Promise.resolve({}); - ctx.ctrl.updateTimeRange(); - }); + let $scope = { + $on: () => {}, + events: { + on: () => {} + } + }; + +HeatmapCtrl.prototype.panel = { + events: { + on: () => {}, + emit: () => {} + } +}; + + beforeEach(() => { + ctx.ctrl = new HeatmapCtrl($scope, $injector, {}); + }); describe('when time series are outside range', function() { beforeEach(function() { @@ -36,7 +40,7 @@ describe('HeatmapCtrl', function() { }); it('should set datapointsOutside', function() { - expect(ctx.ctrl.dataWarning.title).to.be('Data points outside time range'); + expect(ctx.ctrl.dataWarning.title).toBe('Data points outside time range'); }); }); @@ -61,7 +65,7 @@ describe('HeatmapCtrl', function() { }); it('should set datapointsOutside', function() { - expect(ctx.ctrl.dataWarning).to.be(null); + expect(ctx.ctrl.dataWarning).toBe(null); }); }); @@ -72,7 +76,7 @@ describe('HeatmapCtrl', function() { }); it('should set datapointsCount warning', function() { - expect(ctx.ctrl.dataWarning.title).to.be('No data points'); + expect(ctx.ctrl.dataWarning.title).toBe('No data points'); }); }); }); From 805dc3542f780c57f477c61cf9cf475515aa3760 Mon Sep 17 00:00:00 2001 From: Tobias Skarhed Date: Fri, 27 Jul 2018 16:46:41 +0200 Subject: [PATCH 2/2] Remove extra mock --- .../panel/heatmap/specs/heatmap_ctrl.jest.ts | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/public/app/plugins/panel/heatmap/specs/heatmap_ctrl.jest.ts b/public/app/plugins/panel/heatmap/specs/heatmap_ctrl.jest.ts index 70449763856..800c2518f9a 100644 --- a/public/app/plugins/panel/heatmap/specs/heatmap_ctrl.jest.ts +++ b/public/app/plugins/panel/heatmap/specs/heatmap_ctrl.jest.ts @@ -5,26 +5,23 @@ describe('HeatmapCtrl', function() { let ctx = {}; let $injector = { - get: () => {} + get: () => {}, }; let $scope = { $on: () => {}, - events: { - on: () => {} - } }; -HeatmapCtrl.prototype.panel = { + HeatmapCtrl.prototype.panel = { events: { - on: () => {}, - emit: () => {} - } -}; + on: () => {}, + emit: () => {}, + }, + }; - beforeEach(() => { - ctx.ctrl = new HeatmapCtrl($scope, $injector, {}); - }); + beforeEach(() => { + ctx.ctrl = new HeatmapCtrl($scope, $injector, {}); + }); describe('when time series are outside range', function() { beforeEach(function() {