Skip to content

Commit

Permalink
test: 测试用例
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarryxin committed Jan 22, 2024
1 parent a0e1395 commit 6f83cda
Show file tree
Hide file tree
Showing 5 changed files with 421 additions and 138 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ exports[`Calendar custom top 1`] = `
<div
class="adm-calendar-picker-view-body"
>
<div>
<div
data-date="2023-05"
>
<div
class="adm-calendar-picker-view-title"
>
Expand Down Expand Up @@ -620,7 +622,9 @@ exports[`Calendar jump to a day 1`] = `
<div
class="adm-calendar-picker-view-body"
>
<div>
<div
data-date="2021-01"
>
<div
class="adm-calendar-picker-view-title"
>
Expand Down Expand Up @@ -1111,7 +1115,9 @@ exports[`Calendar jump to a day 1`] = `
</div>
</div>
</div>
<div>
<div
data-date="2021-02"
>
<div
class="adm-calendar-picker-view-title"
>
Expand Down Expand Up @@ -1545,7 +1551,9 @@ exports[`Calendar jump to a day 1`] = `
</div>
</div>
</div>
<div>
<div
data-date="2021-03"
>
<div
class="adm-calendar-picker-view-title"
>
Expand Down Expand Up @@ -2024,7 +2032,9 @@ exports[`Calendar jump to a day 1`] = `
</div>
</div>
</div>
<div>
<div
data-date="2021-04"
>
<div
class="adm-calendar-picker-view-title"
>
Expand Down Expand Up @@ -2497,7 +2507,9 @@ exports[`Calendar jump to a day 1`] = `
</div>
</div>
</div>
<div>
<div
data-date="2021-05"
>
<div
class="adm-calendar-picker-view-title"
>
Expand Down Expand Up @@ -2991,7 +3003,9 @@ exports[`Calendar jump to a day 1`] = `
</div>
</div>
</div>
<div>
<div
data-date="2021-06"
>
<div
class="adm-calendar-picker-view-title"
>
Expand Down Expand Up @@ -3458,7 +3472,9 @@ exports[`Calendar jump to a day 1`] = `
</div>
</div>
</div>
<div>
<div
data-date="2021-07"
>
<div
class="adm-calendar-picker-view-title"
>
Expand Down Expand Up @@ -4013,7 +4029,9 @@ exports[`Calendar jump to a day 2`] = `
<div
class="adm-calendar-picker-view-body"
>
<div>
<div
data-date="2023-05"
>
<div
class="adm-calendar-picker-view-title"
>
Expand Down Expand Up @@ -4494,7 +4512,9 @@ exports[`Calendar jump to a day 2`] = `
</div>
</div>
</div>
<div>
<div
data-date="2023-06"
>
<div
class="adm-calendar-picker-view-title"
>
Expand Down Expand Up @@ -4967,7 +4987,9 @@ exports[`Calendar jump to a day 2`] = `
</div>
</div>
</div>
<div>
<div
data-date="2023-07"
>
<div
class="adm-calendar-picker-view-title"
>
Expand Down Expand Up @@ -5461,7 +5483,9 @@ exports[`Calendar jump to a day 2`] = `
</div>
</div>
</div>
<div>
<div
data-date="2023-08"
>
<div
class="adm-calendar-picker-view-title"
>
Expand Down Expand Up @@ -5943,7 +5967,9 @@ exports[`Calendar jump to a day 2`] = `
</div>
</div>
</div>
<div>
<div
data-date="2023-09"
>
<div
class="adm-calendar-picker-view-title"
>
Expand Down Expand Up @@ -6419,7 +6445,9 @@ exports[`Calendar jump to a day 2`] = `
</div>
</div>
</div>
<div>
<div
data-date="2023-10"
>
<div
class="adm-calendar-picker-view-title"
>
Expand Down Expand Up @@ -6916,7 +6944,9 @@ exports[`Calendar jump to a day 2`] = `
</div>
</div>
</div>
<div>
<div
data-date="2023-11"
>
<div
class="adm-calendar-picker-view-title"
>
Expand Down Expand Up @@ -7447,7 +7477,9 @@ exports[`Calendar range mode 1`] = `
<div
class="adm-calendar-picker-view-body"
>
<div>
<div
data-date="2023-05"
>
<div
class="adm-calendar-picker-view-title"
>
Expand Down Expand Up @@ -7993,7 +8025,9 @@ exports[`Calendar single mode 1`] = `
<div
class="adm-calendar-picker-view-body"
>
<div>
<div
data-date="2023-05"
>
<div
class="adm-calendar-picker-view-title"
>
Expand Down Expand Up @@ -8535,7 +8569,9 @@ exports[`Calendar week start on Monday 1`] = `
<div
class="adm-calendar-picker-view-body"
>
<div>
<div
data-date="2023-05"
>
<div
class="adm-calendar-picker-view-title"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ const maxDate: Date = new Date('2023-05-31')
const singleDate: Date = new Date('2023-05-03')
const rangeDate: [Date, Date] = [new Date('2023-05-04'), new Date('2023-05-07')]

beforeEach(() => {
window.HTMLElement.prototype.scrollIntoView = jest.fn()
})

describe('Calendar', () => {
test('a11y', async () => {
await testA11y(<CalendarPickerView />)
Expand Down
3 changes: 2 additions & 1 deletion src/components/calendar-picker/calendar-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import CalendarPickerView, {
CalendarPickerViewProps,
CalendarPickerViewRef,
} from '../calendar-picker-view'
import { sleep } from '../../utils/sleep'

const classPrefix = 'adm-calendar-picker'

Expand Down Expand Up @@ -74,7 +75,7 @@ export const CalendarPicker = forwardRef<
...calendarViewProps
} = props
useEffect(() => {
setImmediate(() => {
sleep(0).then(() => {
const dateRange = calendarRef.current?.getDateRange() ?? null
if (dateRange && dateRange[0]) {
calendarRef.current?.scrollTo(dateRange[0])
Expand Down
4 changes: 4 additions & 0 deletions src/components/calendar-picker/tests/calendar-picker.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ const mixDate: Date = new Date('2023-05-01')
const maxDate: Date = new Date('2023-05-31')
const singleDate: Date = new Date('2023-05-03')

beforeEach(() => {
window.HTMLElement.prototype.scrollIntoView = jest.fn()
})

describe('Calendar', () => {
test('a11y', async () => {
await testA11y(<CalendarPicker />)
Expand Down
Loading

0 comments on commit 6f83cda

Please sign in to comment.