From 7a277c69acd472b0fe281b08d41c7a988ab5f4d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sun, 22 Oct 2017 17:36:50 +0200 Subject: [PATCH] tests: migrated two more tests to jest --- .../app/plugins/panel/graph/data_processor.ts | 4 +--- ...ocessor_specs.ts => data_processor.jest.ts} | 18 +++++++----------- .../{histogram_specs.ts => histogram.jest.ts} | 12 ++++-------- 3 files changed, 12 insertions(+), 22 deletions(-) rename public/app/plugins/panel/graph/specs/{data_processor_specs.ts => data_processor.jest.ts} (71%) rename public/app/plugins/panel/graph/specs/{histogram_specs.ts => histogram.jest.ts} (81%) diff --git a/public/app/plugins/panel/graph/data_processor.ts b/public/app/plugins/panel/graph/data_processor.ts index 855171f3091..453a03927ab 100644 --- a/public/app/plugins/panel/graph/data_processor.ts +++ b/public/app/plugins/panel/graph/data_processor.ts @@ -1,8 +1,6 @@ -/// - import _ from 'lodash'; import TimeSeries from 'app/core/time_series2'; -import {colors} from 'app/core/core'; +import {colors} from 'app/core/utils/colors'; export class DataProcessor { diff --git a/public/app/plugins/panel/graph/specs/data_processor_specs.ts b/public/app/plugins/panel/graph/specs/data_processor.jest.ts similarity index 71% rename from public/app/plugins/panel/graph/specs/data_processor_specs.ts rename to public/app/plugins/panel/graph/specs/data_processor.jest.ts index 85f88aa157c..ea60496af40 100644 --- a/public/app/plugins/panel/graph/specs/data_processor_specs.ts +++ b/public/app/plugins/panel/graph/specs/data_processor.jest.ts @@ -1,7 +1,3 @@ -/// - -import {describe, beforeEach, it, expect} from '../../../../../test/lib/common'; - import {DataProcessor} from '../data_processor'; describe('Graph DataProcessor', function() { @@ -29,7 +25,7 @@ describe('Graph DataProcessor', function() { }); it('Should automatically set xaxis mode to field', () => { - expect(panel.xaxis.mode).to.be('field'); + expect(panel.xaxis.mode).toBe('field'); }); }); @@ -48,16 +44,16 @@ describe('Graph DataProcessor', function() { it('Should return all field names', () => { var fields = processor.getDataFieldNames(dataList, false); - expect(fields).to.contain('hostname'); - expect(fields).to.contain('valueField'); - expect(fields).to.contain('nested.prop1'); - expect(fields).to.contain('nested.value2'); + expect(fields).toContain('hostname'); + expect(fields).toContain('valueField'); + expect(fields).toContain('nested.prop1'); + expect(fields).toContain('nested.value2'); }); it('Should return all number fields', () => { var fields = processor.getDataFieldNames(dataList, true); - expect(fields).to.contain('valueField'); - expect(fields).to.contain('nested.value2'); + expect(fields).toContain('valueField'); + expect(fields).toContain('nested.value2'); }); }); }); diff --git a/public/app/plugins/panel/graph/specs/histogram_specs.ts b/public/app/plugins/panel/graph/specs/histogram.jest.ts similarity index 81% rename from public/app/plugins/panel/graph/specs/histogram_specs.ts rename to public/app/plugins/panel/graph/specs/histogram.jest.ts index 71b3def8d1d..0469b33f259 100644 --- a/public/app/plugins/panel/graph/specs/histogram_specs.ts +++ b/public/app/plugins/panel/graph/specs/histogram.jest.ts @@ -1,7 +1,3 @@ -/// - -import { describe, beforeEach, it, expect } from '../../../../../test/lib/common'; - import { convertValuesToHistogram, getSeriesValues } from '../histogram'; describe('Graph Histogam Converter', function () { @@ -21,7 +17,7 @@ describe('Graph Histogam Converter', function () { ]; let histogram = convertValuesToHistogram(values, bucketSize); - expect(histogram).to.eql(expected); + expect(histogram).toMatchObject(expected); }); it('Should not add empty buckets', () => { @@ -31,7 +27,7 @@ describe('Graph Histogam Converter', function () { ]; let histogram = convertValuesToHistogram(values, bucketSize); - expect(histogram).to.eql(expected); + expect(histogram).toMatchObject(expected); }); }); @@ -50,7 +46,7 @@ describe('Graph Histogam Converter', function () { let expected = [1, 2, 10, 11, 17, 20, 29]; let values = getSeriesValues(data); - expect(values).to.eql(expected); + expect(values).toMatchObject(expected); }); it('Should skip null values', () => { @@ -59,7 +55,7 @@ describe('Graph Histogam Converter', function () { let expected = [1, 2, 10, 11, 17, 20, 29]; let values = getSeriesValues(data); - expect(values).to.eql(expected); + expect(values).toMatchObject(expected); }); }); });