kibana/x-pack/plugins/threat_intelligence/public/common/utils/dates.test.ts
Philippe Oberti 19aa51e5a8
[TIP] Add new Threat intelligence plugin (#136479)
* [TIP] Add Threat Intelligence plugin

- create Threat Intelligence plugin and integrate with Security Solution plugin
- setup jest unit tests, i18n, Cypress tests and  Storybook
- fetch Indicator of Compromise, and display in data-grid
- add flyout components to show IOCs details (table and JSON)
- add new threatIntelInt entry to kbn-doc-links package

https://github.com/elastic/security-team/issues/4329
https://github.com/elastic/security-team/issues/4138
https://github.com/elastic/security-team/issues/4241
https://github.com/elastic/security-team/issues/4242
https://github.com/elastic/security-team/issues/4244
https://github.com/elastic/security-team/issues/4245

Co-authored-by: lgmys <lgmys@pm.me>
Co-authored-by: Maxim Kholod <maxim.kholod@elastic.co>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2022-07-25 19:27:05 +02:00

38 lines
1.4 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
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import moment from 'moment-timezone';
import { fullDateFormatter } from './dates';
import { EMPTY_VALUE } from '../../../common/constants';
const mockValidStringDate = '1 Jan 2022 00:00:00 GMT';
const mockInvalidStringDate = 'invalid date';
moment.suppressDeprecationWarnings = true;
moment.tz.setDefault('UTC');
describe('dates', () => {
describe('fullDateFormatter', () => {
it('should return date string in FULL_DATE format for valid string date', () => {
expect(fullDateFormatter(mockValidStringDate)).toEqual('January 1st 2022 @ 00:00:00');
});
it('should return date string in FULL_DATE format for valid moment date', () => {
const date = moment(mockValidStringDate);
expect(fullDateFormatter(date)).toEqual('January 1st 2022 @ 00:00:00');
});
it('should return EMPTY_VALUE for invalid string date', () => {
expect(fullDateFormatter(mockInvalidStringDate)).toEqual(EMPTY_VALUE);
});
it('should return EMPTY_VALUE for invalid moment date', () => {
const date = moment(mockInvalidStringDate);
expect(fullDateFormatter(date)).toEqual(EMPTY_VALUE);
});
});
});