Skip to content

Commit

Permalink
fix(DatePicker2): pressing enter should correctly display the formatt…
Browse files Browse the repository at this point in the history
…ed value
  • Loading branch information
GCHHCG committed Sep 25, 2024
1 parent 3ce02ed commit 5cf7fdd
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions components/date-picker2/__tests__/index-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,14 +529,27 @@ describe('Picker', () => {
});

it('pressing enter should correctly display the formatted value', () => {
wrapper = mount(
<DatePicker
defaultValue={'2020/02/12'}
format={'DD/MM/YYYY'}
/>
);
function App() {
const [value, setValue] = useState('');
return (
<DatePicker
defaultVisible
value={value}
format={'DD/MM/YYYY'}
outputFormat="YYYY-MM-DD"
onChange={v => {
setValue(v),
assert(
v === dayjs('12/02/2020', 'DD/MM/YYYY').format('YYYY-MM-DD')
);
}}
/>
);
}
wrapper = mount(<App />);
changeInput('12/02/2020');
findInput().simulate('keydown', { keyCode: KEYCODE.ENTER });
assert(getStrValue(wrapper) === dayjs('2020/02/12').format('DD/MM/YYYY'));
assert(getStrValue(wrapper) === '12/02/2020');
});

it('outputFormat', () => {
Expand Down

0 comments on commit 5cf7fdd

Please sign in to comment.