mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
This commit is contained in:
parent
575e864c1b
commit
33dcd1c604
5 changed files with 50 additions and 35 deletions
|
@ -15,6 +15,10 @@ import { addSerializer } from 'jest-specific-snapshot';
|
|||
// Set our default timezone to UTC for tests so we can generate predictable snapshots
|
||||
moment.tz.setDefault('UTC');
|
||||
|
||||
// Freeze time for the tests for predictable snapshots
|
||||
const testTime = new Date(Date.UTC(2019, 5, 1)); // June 1 2019
|
||||
Date.now = jest.fn(() => testTime);
|
||||
|
||||
// Mock EUI generated ids to be consistently predictable for snapshots.
|
||||
jest.mock(`@elastic/eui/lib/components/form/form_row/make_id`, () => () => `generated-id`);
|
||||
|
||||
|
@ -31,16 +35,6 @@ jest.mock('../canvas_plugin_src/renderers/shape/shapes', () => ({
|
|||
},
|
||||
}));
|
||||
|
||||
// Mock datetime parsing so we can get stable results for tests (even while using the `now` format)
|
||||
jest.mock('@elastic/datemath', () => {
|
||||
return {
|
||||
parse: (d, opts) => {
|
||||
const dateMath = jest.requireActual('@elastic/datemath');
|
||||
return dateMath.parse(d, { ...opts, forceNow: new Date(Date.UTC(2019, 5, 1)) }); // June 1 2019
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
// Mock react-datepicker dep used by eui to avoid rendering the entire large component
|
||||
jest.mock('@elastic/eui/packages/react-datepicker', () => {
|
||||
return {
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Storyshots renderers/TimeFilter/components/PrettyDuration with absolute dates 1`] = `
|
||||
<span>
|
||||
~ 5 months ago to ~ 4 months ago
|
||||
</span>
|
||||
`;
|
||||
|
||||
exports[`Storyshots renderers/TimeFilter/components/PrettyDuration with relative dates 1`] = `
|
||||
<span>
|
||||
Last 7 days
|
||||
|
|
|
@ -8,13 +8,6 @@ import { storiesOf } from '@storybook/react';
|
|||
import React from 'react';
|
||||
import { PrettyDuration } from '..';
|
||||
|
||||
storiesOf('renderers/TimeFilter/components/PrettyDuration', module).add(
|
||||
'with relative dates',
|
||||
() => <PrettyDuration from="now-7d" to="now" />
|
||||
);
|
||||
|
||||
/**
|
||||
* Disabling this test due to https://github.com/elastic/kibana/issues/41217
|
||||
* Re-enable when we have a better solution for mocking time used in format_duration
|
||||
*/
|
||||
// .add('with absolute dates', () => <PrettyDuration from="01/01/2019" to="02/01/2019" />);
|
||||
storiesOf('renderers/TimeFilter/components/PrettyDuration', module)
|
||||
.add('with relative dates', () => <PrettyDuration from="now-7d" to="now" />)
|
||||
.add('with absolute dates', () => <PrettyDuration from="01/01/2019" to="02/01/2019" />);
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Storyshots renderers/TimeFilter/components/TimePickerPopover default 1`] = `
|
||||
<div
|
||||
className="euiPopover euiPopover--anchorDownCenter canvasTimePickerPopover"
|
||||
container={null}
|
||||
id="timefilter-popover-trigger-click"
|
||||
onKeyDown={[Function]}
|
||||
onMouseDown={[Function]}
|
||||
onMouseUp={[Function]}
|
||||
onTouchEnd={[Function]}
|
||||
onTouchStart={[Function]}
|
||||
>
|
||||
<div
|
||||
className="euiPopover__anchor canvasTimePickerPopover__anchor"
|
||||
>
|
||||
<button
|
||||
className="canvasTimePickerPopover__button"
|
||||
onClick={[Function]}
|
||||
>
|
||||
<span>
|
||||
~ a month ago to ~ in 3 days
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
|
@ -4,20 +4,15 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Disabling this test due to https://github.com/elastic/kibana/issues/41217
|
||||
* Re-enable when we have a better solution for mocking time used in format_duration
|
||||
*/
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { storiesOf } from '@storybook/react';
|
||||
import moment from 'moment';
|
||||
import React from 'react';
|
||||
import { TimePickerPopover } from '..';
|
||||
|
||||
// import { action } from '@storybook/addon-actions';
|
||||
// import { storiesOf } from '@storybook/react';
|
||||
// import moment from 'moment';
|
||||
// import React from 'react';
|
||||
// import { TimePickerPopover } from '..';
|
||||
const startDate = moment.utc('2019-05-04').toISOString();
|
||||
const endDate = moment.utc('2019-06-04').toISOString();
|
||||
|
||||
// const startDate = moment.utc('2019-05-04').toISOString();
|
||||
// const endDate = moment.utc('2019-06-04').toISOString();
|
||||
|
||||
// storiesOf('renderers/TimeFilter/components/TimePickerPopover', module).add('default', () => (
|
||||
// <TimePickerPopover from={startDate} to={endDate} onSelect={action('onSelect')} />
|
||||
// ));
|
||||
storiesOf('renderers/TimeFilter/components/TimePickerPopover', module).add('default', () => (
|
||||
<TimePickerPopover from={startDate} to={endDate} onSelect={action('onSelect')} />
|
||||
));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue