335 workflow implement workflow cron triggers backend (#9988)
[Backend side] Add cron triggers to workflow Closes https://github.com/twentyhq/core-team-issues/issues/335
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import { isDefined } from '../isDefined';
|
||||
describe('isDefined', () => {
|
||||
it('returns true if value is not undefined nor null', () => {
|
||||
expect(isDefined('')).toBe(true);
|
||||
});
|
||||
|
||||
it('returns false if value is null', () => {
|
||||
expect(isDefined(null)).toBe(false);
|
||||
});
|
||||
|
||||
it('returns false if value is undefined', () => {
|
||||
expect(isDefined(undefined)).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
import { isValidUuid } from '../isValidUuid';
|
||||
|
||||
describe('isValidUuid', () => {
|
||||
it('should return true for a valid UUID', () => {
|
||||
expect(isValidUuid('123e4567-e89b-12d3-a456-426614174000')).toBe(true);
|
||||
expect(isValidUuid('550e8400-e29b-41d4-a716-446655440000')).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false for an invalid UUID', () => {
|
||||
expect(isValidUuid('invalid-uuid')).toBe(false);
|
||||
expect(isValidUuid('12345')).toBe(false);
|
||||
expect(isValidUuid('550e8400e29b41d4a716446655440000')).toBe(false);
|
||||
expect(isValidUuid('')).toBe(false);
|
||||
expect(isValidUuid('123e4567-e89b-12d3-a456-42661417400-')).toBe(false);
|
||||
expect(isValidUuid('123e4567-e89b-12d3-a456-42661417400')).toBe(false);
|
||||
expect(isValidUuid('123e4567-e89b-12d3-a456-42661417400)')).toBe(false);
|
||||
expect(isValidUuid('123e4567-e89b-12d3-a456-4266141740001')).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,15 @@
|
||||
import { isValidLocale } from '../isValidLocale';
|
||||
import { APP_LOCALES } from 'src/constants/Locales';
|
||||
|
||||
describe('isValidLocale', () => {
|
||||
it('should return true for valid locales', () => {
|
||||
Object.keys(APP_LOCALES).forEach((locale) => {
|
||||
expect(isValidLocale(locale)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
it('should return false for invalid locales', () => {
|
||||
expect(isValidLocale('invalidLocale')).toBe(false);
|
||||
expect(isValidLocale(null)).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,3 @@
|
||||
export * from './isValidUuid';
|
||||
export * from './isDefined';
|
||||
export * from './isValidLocale';
|
||||
@@ -0,0 +1,4 @@
|
||||
import { isNull, isUndefined } from '@sniptt/guards';
|
||||
|
||||
export const isDefined = <T>(value: T | null | undefined): value is T =>
|
||||
!isUndefined(value) && !isNull(value);
|
||||
@@ -0,0 +1,5 @@
|
||||
import { APP_LOCALES } from 'src/constants/Locales';
|
||||
|
||||
export const isValidLocale = (
|
||||
value: string | null,
|
||||
): value is keyof typeof APP_LOCALES => value !== null && value in APP_LOCALES;
|
||||
@@ -0,0 +1,5 @@
|
||||
export const isValidUuid = (value: string): boolean => {
|
||||
const uuidRegex =
|
||||
/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
||||
return uuidRegex.test(value);
|
||||
};
|
||||
Reference in New Issue
Block a user