From 954558161eccd2e4f2043a62ffb5333fde4dfae9 Mon Sep 17 00:00:00 2001 From: ebb-tide Date: Mon, 30 Apr 2018 15:38:38 -0700 Subject: [PATCH] Fix tests and address PR review items --- .../components/GraphOptionsDecimalPlaces.tsx | 5 ++-- ui/test/utils/timeSeriesTransformers.test.js | 29 ++++++++++++------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/ui/src/dashboards/components/GraphOptionsDecimalPlaces.tsx b/ui/src/dashboards/components/GraphOptionsDecimalPlaces.tsx index 06d952da29..0244c7fced 100644 --- a/ui/src/dashboards/components/GraphOptionsDecimalPlaces.tsx +++ b/ui/src/dashboards/components/GraphOptionsDecimalPlaces.tsx @@ -1,5 +1,4 @@ import React, {PureComponent} from 'react' -import {} from 'src/dashboards/constants' import {ErrorHandling} from 'src/shared/decorators/errors' import OptIn from 'src/shared/components/OptIn' @@ -19,7 +18,8 @@ class GraphOptionsDecimalPlaces extends PureComponent { constructor(props: Props) { super(props) } - public onSetValue = valueFromSelector => { + + public onSetValue = (valueFromSelector: string): void => { let digits let isEnforced if (valueFromSelector === fixedValueString) { @@ -37,6 +37,7 @@ class GraphOptionsDecimalPlaces extends PureComponent { } this.props.onDecimalPlacesChange({digits, isEnforced}) } + public render() { const {digits, isEnforced} = this.props return ( diff --git a/ui/test/utils/timeSeriesTransformers.test.js b/ui/test/utils/timeSeriesTransformers.test.js index 35457de74a..ce953435ff 100644 --- a/ui/test/utils/timeSeriesTransformers.test.js +++ b/ui/test/utils/timeSeriesTransformers.test.js @@ -9,7 +9,10 @@ import { } from 'src/dashboards/utils/tableGraph' import {DEFAULT_SORT_DIRECTION} from 'src/shared/constants/tableGraph' -import {DEFAULT_TIME_FORMAT} from 'src/dashboards/constants' +import { + DEFAULT_TIME_FORMAT, + DEFAULT_DECIMAL_PLACES, +} from 'src/dashboards/constants' describe('timeSeriesToDygraph', () => { it('parses a raw InfluxDB response into a dygraph friendly data format', () => { @@ -534,7 +537,7 @@ describe('transformTableData', () => { const sort = {field: 'f1', direction: DEFAULT_SORT_DIRECTION} const tableOptions = {verticalTimeAxis: true} const timeFormat = DEFAULT_TIME_FORMAT - + const decimalPlaces = DEFAULT_DECIMAL_PLACES const fieldOptions = [ {internalName: 'time', displayName: 'Time', visible: true}, {internalName: 'f1', displayName: '', visible: true}, @@ -546,7 +549,8 @@ describe('transformTableData', () => { sort, fieldOptions, tableOptions, - timeFormat + timeFormat, + decimalPlaces ) const expected = [ ['time', 'f1', 'f2'], @@ -568,6 +572,7 @@ describe('transformTableData', () => { const sort = {field: 'time', direction: DEFAULT_SORT_DIRECTION} const tableOptions = {verticalTimeAxis: true} const timeFormat = DEFAULT_TIME_FORMAT + const decimalPlaces = DEFAULT_DECIMAL_PLACES const fieldOptions = [ {internalName: 'time', displayName: 'Time', visible: true}, {internalName: 'f1', displayName: '', visible: false}, @@ -579,7 +584,8 @@ describe('transformTableData', () => { sort, fieldOptions, tableOptions, - timeFormat + timeFormat, + decimalPlaces ) const expected = [['time', 'f2'], [1000, 2000], [2000, 3000], [3000, 1000]] @@ -598,7 +604,7 @@ describe('transformTableData', () => { const sort = {field: 'f1', direction: DEFAULT_SORT_DIRECTION} const tableOptions = {verticalTimeAxis: true} const timeFormat = DEFAULT_TIME_FORMAT - + const decimalPlaces = DEFAULT_DECIMAL_PLACES const fieldOptions = [ {internalName: 'time', displayName: 'Time', visible: true}, {internalName: 'f1', displayName: '', visible: false}, @@ -610,7 +616,8 @@ describe('transformTableData', () => { sort, fieldOptions, tableOptions, - timeFormat + timeFormat, + decimalPlaces ) const expected = [['time', 'f2'], [2000, 3000], [3000, 1000], [1000, 2000]] @@ -631,7 +638,7 @@ describe('if verticalTimeAxis is false', () => { const sort = {field: 'time', direction: DEFAULT_SORT_DIRECTION} const tableOptions = {verticalTimeAxis: false} const timeFormat = DEFAULT_TIME_FORMAT - + const decimalPlaces = DEFAULT_DECIMAL_PLACES const fieldOptions = [ {internalName: 'time', displayName: 'Time', visible: true}, {internalName: 'f1', displayName: '', visible: true}, @@ -643,7 +650,8 @@ describe('if verticalTimeAxis is false', () => { sort, fieldOptions, tableOptions, - timeFormat + timeFormat, + decimalPlaces ) const expected = [ @@ -666,7 +674,7 @@ describe('if verticalTimeAxis is false', () => { const sort = {field: 'f1', direction: DEFAULT_SORT_DIRECTION} const tableOptions = {verticalTimeAxis: false} const timeFormat = DEFAULT_TIME_FORMAT - + const decimalPlaces = DEFAULT_DECIMAL_PLACES const fieldOptions = [ {internalName: 'time', displayName: 'Time', visible: true}, {internalName: 'f1', displayName: '', visible: false}, @@ -678,7 +686,8 @@ describe('if verticalTimeAxis is false', () => { sort, fieldOptions, tableOptions, - timeFormat + timeFormat, + decimalPlaces ) const expected = [['time', 2000, 3000, 1000], ['f2', 3000, 1000, 2000]]