-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<Form | ||
onSubmit={() => { }} | ||
render={({ handleSubmit, submitting, pristine, invalid }) => ( | ||
<form onSubmit={handleSubmit}> | ||
<Field | ||
component={Datepicker} | ||
id="ruleset-start-date" | ||
label="Start Date" | ||
name="startDate" | ||
required | ||
usePortal | ||
validate={requiredValidator} | ||
/> | ||
<Button | ||
disabled={submitting || invalid || pristine} | ||
id="submit-button" | ||
type="submit" | ||
> | ||
Submit | ||
</Button> | ||
</form> | ||
)} | ||
/> | ||
); | ||
}; | ||
|
||
export default SimpleDateForm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(<SimpleDateForm />); | ||
|
||
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(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './SimpleDateForm'; |