Add number as valid type of bound

pull/10616/head
Andrew Watkins 2017-10-05 16:25:10 -07:00
parent 59ad62686f
commit 8d7d0bd254
2 changed files with 6 additions and 3 deletions

View File

@ -48,8 +48,8 @@ describe.only('Normalizers.DashboardTime', () => {
})
it('can remove a timeRange when upper and lower bounds are of the wrong type', () => {
const badTime = {dashboardID, upper: 2017, lower}
const reallyBadTime = {dashboardID, upper, lower: {foo: 'bar'}}
const badTime = {dashboardID, upper: [], lower}
const reallyBadTime = {dashboardID, upper, lower: {bad: 'time'}}
const ranges = [timeRange, badTime, reallyBadTime]
const actual = normalizer(ranges)

View File

@ -1,3 +1,5 @@
import _ from 'lodash'
const dashtime = ranges => {
if (!Array.isArray(ranges)) {
return []
@ -27,7 +29,8 @@ const dashtime = ranges => {
return false
}
const isCorrectType = bound => typeof bound === 'string' || bound === null
const isCorrectType = bound =>
_.isString(bound) || _.isNull(bound) || _.isInteger(bound)
if (!isCorrectType(lower) || !isCorrectType(upper)) {
return false