mirror of
https://github.com/strapi/strapi.git
synced 2025-12-12 07:27:46 +00:00
Fix review comments
This commit is contained in:
parent
e144a50af8
commit
2671d3fab0
@ -17,7 +17,11 @@ function GenericInput({ type, onChange, value, ...rest }) {
|
||||
|
||||
return (
|
||||
<DateWrapper type={type}>
|
||||
<DatePicker onChange={e => onChange(e.target.value._d)} value={momentValue} {...rest} />
|
||||
<DatePicker
|
||||
onChange={e => onChange(e.target.value.format('YYYY-MM-DD'))}
|
||||
value={momentValue}
|
||||
{...rest}
|
||||
/>
|
||||
</DateWrapper>
|
||||
);
|
||||
}
|
||||
@ -27,7 +31,11 @@ function GenericInput({ type, onChange, value, ...rest }) {
|
||||
|
||||
return (
|
||||
<DateWrapper type={type}>
|
||||
<DateTime onChange={e => onChange(e.target.value)} value={momentValue} {...rest} />
|
||||
<DateTime
|
||||
onChange={e => onChange(e.target.value.format('YYYY-MM-DD'))}
|
||||
value={momentValue}
|
||||
{...rest}
|
||||
/>
|
||||
</DateWrapper>
|
||||
);
|
||||
}
|
||||
|
||||
@ -1,11 +1,16 @@
|
||||
import React from 'react';
|
||||
import { render, fireEvent } from '@testing-library/react';
|
||||
import { BrowserRouter } from 'react-router-dom';
|
||||
|
||||
import AttributeFilter from '..';
|
||||
import addressCt from '../../../../../../../../admin-test-utils/lib/fixtures/collectionTypes/address';
|
||||
import addressMetaData from '../../../../../../../../admin-test-utils/lib/fixtures/metaData/address';
|
||||
|
||||
class MockDate extends Date {
|
||||
constructor() {
|
||||
super(1992, 5, 21);
|
||||
}
|
||||
}
|
||||
|
||||
jest.mock('react-intl', () => ({
|
||||
// eslint-disable-next-line react/prop-types
|
||||
FormattedMessage: ({ id }) => <option value={id}>{id}</option>,
|
||||
@ -111,6 +116,17 @@ const renderComponent = () =>
|
||||
);
|
||||
|
||||
describe('AttributeFilter', () => {
|
||||
let realDate;
|
||||
|
||||
beforeEach(() => {
|
||||
realDate = global.Date;
|
||||
global.Date = MockDate;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
global.Date = realDate;
|
||||
});
|
||||
|
||||
it('snapshots the filter dropdown with a set of valid fields', () => {
|
||||
const { container } = renderComponent();
|
||||
|
||||
@ -339,7 +355,7 @@ describe('AttributeFilter', () => {
|
||||
name="start_date"
|
||||
tabindex="0"
|
||||
type="text"
|
||||
value="June 29, 2021"
|
||||
value="June 21, 1992"
|
||||
/>
|
||||
`);
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user