From 867816d2cd3baa4be3acec46106a968923e8150a Mon Sep 17 00:00:00 2001 From: Violet Voronetzky Date: Wed, 25 Mar 2020 16:12:21 +0200 Subject: [PATCH] Fixed default options --- src/common/kustoChartHelper.ts | 1 + src/common/utilities.ts | 6 +++--- test/highcharts/chart.test.ts | 30 ++++++++++++++++++++---------- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/common/kustoChartHelper.ts b/src/common/kustoChartHelper.ts index 3661590..6c82b14 100644 --- a/src/common/kustoChartHelper.ts +++ b/src/common/kustoChartHelper.ts @@ -43,6 +43,7 @@ export class KustoChartHelper implements IChartHelper { exceedMaxDataPointLabel: 'OTHER', aggregationType: AggregationType.Sum, chartTheme: ChartTheme.Light, + getUtcOffset: () => { return 0; }, legendOptions: { isEnabled: true } diff --git a/src/common/utilities.ts b/src/common/utilities.ts index 12701c7..ef4ede1 100644 --- a/src/common/utilities.ts +++ b/src/common/utilities.ts @@ -25,10 +25,10 @@ export class Utilities { /** * Returns the value of the local date after adding the desired offset (from UTC) * @param dateStr - The string value that represents the date to transform. - * @param getUtcOffset - [Optional] Callback that returnd offset in hours from UTC. If not provided, the utcOffset will be 0 + * @param getUtcOffset - Callback that returns the offset in hours from UTC. * @returns The value of the date + the desired UTC offset */ - public static getDateValue(dateStr: string, getUtcOffset?: (dateStr: string) => number): number { + public static getDateValue(dateStr: string, getUtcOffset: (dateStr: string) => number): number { const date = new Date(dateStr); if (date.toDateString() === 'Invalid Date') { @@ -36,7 +36,7 @@ export class Utilities { } // Add UTC offset to the date - const utcOffset = getUtcOffset ? getUtcOffset(dateStr) : 0; + const utcOffset = getUtcOffset(dateStr); const utcOffsetInMilliseconds = utcOffset * 60 * 60 * 1000; const localDateValue = date.valueOf(); diff --git a/test/highcharts/chart.test.ts b/test/highcharts/chart.test.ts index 603b865..adbba19 100644 --- a/test/highcharts/chart.test.ts +++ b/test/highcharts/chart.test.ts @@ -89,7 +89,8 @@ describe('Unit tests for Chart methods', () => { columnsSelection: { xAxis: columns[1], // timestamp yAxes: [columns[3]] // request_count - } + }, + getUtcOffset: () => { return 0; } }, queryResultData: { rows: rows, @@ -232,7 +233,8 @@ describe('Unit tests for Chart methods', () => { columnsSelection: { xAxis: columns[0], // country yAxes: [columns[1]] // count - } + }, + getUtcOffset: () => { return 0; } }, queryResultData: { rows: rows, @@ -276,7 +278,8 @@ describe('Unit tests for Chart methods', () => { columnsSelection: { xAxis: columns[1], // timestamp yAxes: [columns[3]] // request_count - } + }, + getUtcOffset: () => { return 0; } }, queryResultData: { rows: rows, @@ -329,7 +332,8 @@ describe('Unit tests for Chart methods', () => { xAxis: columns[0], // country yAxes: [columns[2]], // request_count splitBy: [columns[1]] // city - } + }, + getUtcOffset: () => { return 0; } }, queryResultData: { rows: rows, @@ -407,7 +411,8 @@ describe('Unit tests for Chart methods', () => { xAxis: columns[1], // timestamp yAxes: [columns[3]], // request_count splitBy: [columns[2]], // city - } + }, + getUtcOffset: () => { return 0; } }, queryResultData: { rows: rows, @@ -478,7 +483,8 @@ describe('Unit tests for Chart methods', () => { xAxis: columns[0], // country yAxes: [columns[2]], // request_count splitBy: [columns[1]] // city - } + }, + getUtcOffset: () => { return 0; } }, queryResultData: { rows: rows, @@ -533,7 +539,8 @@ describe('Unit tests for Chart methods', () => { columnsSelection: { xAxis: columns[1], // city yAxes: [columns[2]], // request_count - } + }, + getUtcOffset: () => { return 0; } }, queryResultData: { rows: rows, @@ -585,7 +592,8 @@ describe('Unit tests for Chart methods', () => { columnsSelection: { xAxis: columns[1], // city yAxes: [columns[2]], // request_count - } + }, + getUtcOffset: () => { return 0; } }, queryResultData: { rows: rows, @@ -657,7 +665,8 @@ describe('Unit tests for Chart methods', () => { xAxis: columns[0], // country yAxes: [columns[2]], // request_count splitBy: [columns[1]] // city - } + }, + getUtcOffset: () => { return 0; } }, queryResultData: { rows: rows, @@ -732,7 +741,8 @@ describe('Unit tests for Chart methods', () => { xAxis: columns[0], // browser yAxes: [columns[3]], // usage splitBy: [columns[1], columns[2]] // version, minor_version - } + }, + getUtcOffset: () => { return 0; } }, queryResultData: { rows: rows,