This repository has been archived by the owner on Mar 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
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
9 changed files
with
18,939 additions
and
1,717 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
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
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,66 @@ | ||
import { getDateRangeWidgetConfiguration } from '../../__tests__/factories' | ||
import { DateRangeWidget } from '../../src' | ||
|
||
const Form = ({ | ||
children, | ||
handleSubmit | ||
}: { | ||
children: React.ReactNode | ||
handleSubmit: (...args: any) => void | ||
}) => { | ||
return ( | ||
<form | ||
onSubmit={ev => { | ||
ev.preventDefault() | ||
const formData = new FormData(ev.currentTarget) | ||
handleSubmit([...formData.entries()]) | ||
}} | ||
> | ||
{children} | ||
<button>submit</button> | ||
</form> | ||
) | ||
} | ||
|
||
describe('<DateRangeWidget />', () => { | ||
afterEach(() => { | ||
cy.clearLocalStorage() | ||
}) | ||
|
||
it('test', () => { | ||
const stubbedHandleSubmit = cy.stub().as('stubbedHandleSubmit') | ||
|
||
cy.viewport(700, 600) | ||
|
||
localStorage.setItem( | ||
'formSelection', | ||
JSON.stringify({ | ||
dataset: 'fake', | ||
inputs: { | ||
date_range_start: '2023-09-30', | ||
date_range_end: '2025-02-10' | ||
} | ||
}) | ||
) | ||
|
||
cy.mount( | ||
<Form handleSubmit={stubbedHandleSubmit}> | ||
<DateRangeWidget | ||
configuration={getDateRangeWidgetConfiguration()} | ||
constraints={['2023-10-05', '2023-10-11', '2023-10-30']} | ||
error='Start date and End date are required' | ||
/> | ||
</Form> | ||
) | ||
// cy.get('[data-trigger="true"]').first().click() | ||
// cy.findByText('15').click() | ||
// cy.findByText('submit').trigger('pointerdown', { | ||
// pointerId: 0 | ||
// }) | ||
|
||
// cy.get('@stubbedHandleSubmit').should('have.been.calledWith', [ | ||
// ['date_range_start', '2023-09-15'], | ||
// ['date_range_end', '2025-02-10'] | ||
// ]) | ||
}) | ||
}) |
Oops, something went wrong.