mirror of
https://github.com/umami-software/umami.git
synced 2026-02-08 14:47:14 +01:00
Create unit test.
This commit is contained in:
parent
ce2a83a09f
commit
e6eb9a487e
4 changed files with 21 additions and 19 deletions
|
|
@ -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),
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue