Create unit test.
This commit is contained in:
@@ -30,6 +30,8 @@ export const FILTER_RANGE = 'filter-range';
|
||||
export const FILTER_REFERRERS = 'filter-referrers';
|
||||
export const FILTER_PAGES = 'filter-pages';
|
||||
|
||||
export const UNIT_TYPES = ['year', 'month', 'hour', 'day'];
|
||||
|
||||
export const USER_FILTER_TYPES = {
|
||||
all: 'All',
|
||||
username: 'Username',
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import moment from 'moment';
|
||||
import * as yup from 'yup';
|
||||
import { UNIT_TYPES } from './constants';
|
||||
|
||||
export const DateRangeValidation = {
|
||||
startAt: yup.number().integer().required(),
|
||||
@@ -20,5 +21,11 @@ export function getFilterValidation(matchRegex) {
|
||||
export const TimezoneTest = yup.string().test(
|
||||
'timezone',
|
||||
() => `Invalid timezone`,
|
||||
value => !moment.tz.zone(value),
|
||||
value => !value || !moment.tz.zone(value),
|
||||
);
|
||||
|
||||
export const UnitTypeTest = yup.string().test(
|
||||
'unit',
|
||||
() => `Invalid unit`,
|
||||
value => !value || !UNIT_TYPES.includes(value),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user