* Changed alerting API endpoints urls, bodies and params to follow Kibana STYLEGUIDE * Changed alerting REST API to keep the pattern 'alerts/alert/{id}' * fixed tests * fixed tests * Fixed jest tests * Renamed plugin from alerting to alerts * fixed tests * fixed tests * Fixed alert type check error * Fixed find api * fixed type checks * fixed tests security issues * Fixed view in app * - Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
29 lines
1 KiB
TypeScript
29 lines
1 KiB
TypeScript
/*
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
* or more contributor license agreements. Licensed under the Elastic License;
|
|
* you may not use this file except in compliance with the Elastic License.
|
|
*/
|
|
|
|
import { DateFromString } from './date_from_string';
|
|
import { right, isLeft } from 'fp-ts/lib/Either';
|
|
|
|
describe('DateFromString', () => {
|
|
test('validated and parses a string into a Date', () => {
|
|
const date = new Date(1973, 10, 30);
|
|
expect(DateFromString.decode(date.toISOString())).toEqual(right(date));
|
|
});
|
|
|
|
test('validated and returns a failure for an actual Date', () => {
|
|
const date = new Date(1973, 10, 30);
|
|
expect(isLeft(DateFromString.decode(date))).toEqual(true);
|
|
});
|
|
|
|
test('validated and returns a failure for an invalid Date string', () => {
|
|
expect(isLeft(DateFromString.decode('1234-23-45'))).toEqual(true);
|
|
});
|
|
|
|
test('validated and returns a failure for a null value', () => {
|
|
expect(isLeft(DateFromString.decode(null))).toEqual(true);
|
|
});
|
|
});
|