diff --git a/src/components/SimpleDateForm/SimpleDateForm.js b/src/components/SimpleDateForm/SimpleDateForm.js new file mode 100644 index 0000000..261995c --- /dev/null +++ b/src/components/SimpleDateForm/SimpleDateForm.js @@ -0,0 +1,34 @@ +import React from 'react'; +import { Form, Field } from 'react-final-form'; +import { Button, Datepicker } from '@folio/stripes/components'; +import { requiredValidator } from '@folio/stripes-erm-components'; + +const SimpleDateForm = () => { + return ( +
{ }} + render={({ handleSubmit, submitting, pristine, invalid }) => ( + + + + + )} + /> + ); +}; + +export default SimpleDateForm; diff --git a/src/components/SimpleDateForm/SimpleDateForm.test.js b/src/components/SimpleDateForm/SimpleDateForm.test.js new file mode 100644 index 0000000..7155117 --- /dev/null +++ b/src/components/SimpleDateForm/SimpleDateForm.test.js @@ -0,0 +1,23 @@ +import React from 'react'; +import { renderWithIntl, Datepicker, Button } from '@folio/stripes-erm-testing'; +import { waitFor, screen } from '@folio/jest-config-stripes/testing-library/react'; +import SimpleDateForm from './SimpleDateForm'; + +describe('SimpleDateForm', () => { + test('Button should be enabled when date is valid', async () => { + renderWithIntl(); + + await waitFor(async () => { + const dateInput = Datepicker({ id: 'ruleset-start-date' }); + await dateInput.focus(); + await dateInput.fillIn('01/30/2024'); + await dateInput.blur(); + screen.debug(); + }); + + await Datepicker({ id: 'ruleset-start-date' }).has({ inputValue: '01/30/2024' }); + + await Button({ id: 'submit-button' }).has({ disabled: false }); + // screen.debug(); + }); +}); diff --git a/src/components/SimpleDateForm/index.js b/src/components/SimpleDateForm/index.js new file mode 100644 index 0000000..5166760 --- /dev/null +++ b/src/components/SimpleDateForm/index.js @@ -0,0 +1 @@ +export { default } from './SimpleDateForm';