Add number as valid type of bound
parent
59ad62686f
commit
8d7d0bd254
|
@ -48,8 +48,8 @@ describe.only('Normalizers.DashboardTime', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can remove a timeRange when upper and lower bounds are of the wrong type', () => {
|
it('can remove a timeRange when upper and lower bounds are of the wrong type', () => {
|
||||||
const badTime = {dashboardID, upper: 2017, lower}
|
const badTime = {dashboardID, upper: [], lower}
|
||||||
const reallyBadTime = {dashboardID, upper, lower: {foo: 'bar'}}
|
const reallyBadTime = {dashboardID, upper, lower: {bad: 'time'}}
|
||||||
const ranges = [timeRange, badTime, reallyBadTime]
|
const ranges = [timeRange, badTime, reallyBadTime]
|
||||||
|
|
||||||
const actual = normalizer(ranges)
|
const actual = normalizer(ranges)
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import _ from 'lodash'
|
||||||
|
|
||||||
const dashtime = ranges => {
|
const dashtime = ranges => {
|
||||||
if (!Array.isArray(ranges)) {
|
if (!Array.isArray(ranges)) {
|
||||||
return []
|
return []
|
||||||
|
@ -27,7 +29,8 @@ const dashtime = ranges => {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
const isCorrectType = bound => typeof bound === 'string' || bound === null
|
const isCorrectType = bound =>
|
||||||
|
_.isString(bound) || _.isNull(bound) || _.isInteger(bound)
|
||||||
|
|
||||||
if (!isCorrectType(lower) || !isCorrectType(upper)) {
|
if (!isCorrectType(lower) || !isCorrectType(upper)) {
|
||||||
return false
|
return false
|
||||||
|
|
Loading…
Reference in New Issue