forked from ant-design/ant-design-mobile
-
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.
feat(DatePickerView): support till now
- Loading branch information
1 parent
6337f96
commit df72c23
Showing
5 changed files
with
84 additions
and
25 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
29 changes: 29 additions & 0 deletions
29
src/components/date-picker-view/tests/date-picker-view.test.tsx
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,29 @@ | ||
import { render, testA11y, fireEvent, screen, act } from 'testing' | ||
import React from 'react' | ||
import DatePickerView from '../' | ||
|
||
const now = new Date() | ||
|
||
describe('DatePickerView', () => { | ||
test('passes a11y test', async () => { | ||
await act(async () => { | ||
await testA11y(<DatePickerView />) | ||
}) | ||
}) | ||
|
||
test('till now should be work', async () => { | ||
const fn = jest.fn() | ||
render( | ||
<DatePickerView defaultValue={now} max={now} tillNow onChange={fn} /> | ||
) | ||
|
||
const nowEl = await screen.findByText('至今') | ||
fireEvent.click(nowEl) | ||
await act(async () => { | ||
await Promise.resolve() | ||
}) | ||
const res = fn.mock.calls[0][0] | ||
expect(res.toDateString()).toEqual(now.toDateString()) | ||
expect(res.tillNow).toBeTruthy() | ||
}) | ||
}) |
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