diff --git a/src/components/calendar-picker-view/tests/__snapshots__/calendar-picker-view.test.tsx.snap b/src/components/calendar-picker-view/tests/__snapshots__/calendar-picker-view.test.tsx.snap index b0fa98624c..972673662d 100644 --- a/src/components/calendar-picker-view/tests/__snapshots__/calendar-picker-view.test.tsx.snap +++ b/src/components/calendar-picker-view/tests/__snapshots__/calendar-picker-view.test.tsx.snap @@ -56,7 +56,9 @@ exports[`Calendar custom top 1`] = `
-
+
@@ -620,7 +622,9 @@ exports[`Calendar jump to a day 1`] = `
-
+
@@ -1111,7 +1115,9 @@ exports[`Calendar jump to a day 1`] = `
-
+
@@ -1545,7 +1551,9 @@ exports[`Calendar jump to a day 1`] = `
-
+
@@ -2024,7 +2032,9 @@ exports[`Calendar jump to a day 1`] = `
-
+
@@ -2497,7 +2507,9 @@ exports[`Calendar jump to a day 1`] = `
-
+
@@ -2991,7 +3003,9 @@ exports[`Calendar jump to a day 1`] = `
-
+
@@ -3458,7 +3472,9 @@ exports[`Calendar jump to a day 1`] = `
-
+
@@ -4013,7 +4029,9 @@ exports[`Calendar jump to a day 2`] = `
-
+
@@ -4494,7 +4512,9 @@ exports[`Calendar jump to a day 2`] = `
-
+
@@ -4967,7 +4987,9 @@ exports[`Calendar jump to a day 2`] = `
-
+
@@ -5461,7 +5483,9 @@ exports[`Calendar jump to a day 2`] = `
-
+
@@ -5943,7 +5967,9 @@ exports[`Calendar jump to a day 2`] = `
-
+
@@ -6419,7 +6445,9 @@ exports[`Calendar jump to a day 2`] = `
-
+
@@ -6916,7 +6944,9 @@ exports[`Calendar jump to a day 2`] = `
-
+
@@ -7447,7 +7477,9 @@ exports[`Calendar range mode 1`] = `
-
+
@@ -7993,7 +8025,9 @@ exports[`Calendar single mode 1`] = `
-
+
@@ -8535,7 +8569,9 @@ exports[`Calendar week start on Monday 1`] = `
-
+
diff --git a/src/components/calendar-picker-view/tests/calendar-picker-view.test.tsx b/src/components/calendar-picker-view/tests/calendar-picker-view.test.tsx index 43eecb0f87..538dc9683b 100644 --- a/src/components/calendar-picker-view/tests/calendar-picker-view.test.tsx +++ b/src/components/calendar-picker-view/tests/calendar-picker-view.test.tsx @@ -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() diff --git a/src/components/calendar-picker/calendar-picker.tsx b/src/components/calendar-picker/calendar-picker.tsx index 99df245e03..04f9695d5f 100644 --- a/src/components/calendar-picker/calendar-picker.tsx +++ b/src/components/calendar-picker/calendar-picker.tsx @@ -11,6 +11,7 @@ import CalendarPickerView, { CalendarPickerViewProps, CalendarPickerViewRef, } from '../calendar-picker-view' +import { sleep } from '../../utils/sleep' const classPrefix = 'adm-calendar-picker' @@ -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]) diff --git a/src/components/calendar-picker/tests/calendar-picker.test.tsx b/src/components/calendar-picker/tests/calendar-picker.test.tsx index e00891c328..0f041b4d6a 100644 --- a/src/components/calendar-picker/tests/calendar-picker.test.tsx +++ b/src/components/calendar-picker/tests/calendar-picker.test.tsx @@ -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() diff --git a/src/components/config-provider/tests/__snapshots__/config-provider.test.tsx.snap b/src/components/config-provider/tests/__snapshots__/config-provider.test.tsx.snap index 032fdb81b8..9962043274 100644 --- a/src/components/config-provider/tests/__snapshots__/config-provider.test.tsx.snap +++ b/src/components/config-provider/tests/__snapshots__/config-provider.test.tsx.snap @@ -778,7 +778,9 @@ exports[`ConfigProvider should display the text as da-DK 1`] = `
-
+
@@ -1262,7 +1264,9 @@ exports[`ConfigProvider should display the text as da-DK 1`] = `
-
+
@@ -1738,7 +1742,9 @@ exports[`ConfigProvider should display the text as da-DK 1`] = `
-
+
@@ -2235,7 +2241,9 @@ exports[`ConfigProvider should display the text as da-DK 1`] = `
-
+
@@ -2705,7 +2713,9 @@ exports[`ConfigProvider should display the text as da-DK 1`] = `
-
+
@@ -3196,7 +3206,9 @@ exports[`ConfigProvider should display the text as da-DK 1`] = `
-
+
@@ -3675,7 +3687,9 @@ exports[`ConfigProvider should display the text as da-DK 1`] = `
-
+
@@ -5422,7 +5436,9 @@ exports[`ConfigProvider should display the text as en 1`] = `
-
+
@@ -5906,7 +5922,9 @@ exports[`ConfigProvider should display the text as en 1`] = `
-
+
@@ -6382,7 +6400,9 @@ exports[`ConfigProvider should display the text as en 1`] = `
-
+
@@ -6879,7 +6899,9 @@ exports[`ConfigProvider should display the text as en 1`] = `
-
+
@@ -7349,7 +7371,9 @@ exports[`ConfigProvider should display the text as en 1`] = `
-
+
@@ -7840,7 +7864,9 @@ exports[`ConfigProvider should display the text as en 1`] = `
-
+
@@ -8319,7 +8345,9 @@ exports[`ConfigProvider should display the text as en 1`] = `
-
+
@@ -10066,7 +10094,9 @@ exports[`ConfigProvider should display the text as es 1`] = `
-
+
@@ -10550,7 +10580,9 @@ exports[`ConfigProvider should display the text as es 1`] = `
-
+
@@ -11026,7 +11058,9 @@ exports[`ConfigProvider should display the text as es 1`] = `
-
+
@@ -11523,7 +11557,9 @@ exports[`ConfigProvider should display the text as es 1`] = `
-
+
@@ -11993,7 +12029,9 @@ exports[`ConfigProvider should display the text as es 1`] = `
-
+
@@ -12484,7 +12522,9 @@ exports[`ConfigProvider should display the text as es 1`] = `
-
+
@@ -12963,7 +13003,9 @@ exports[`ConfigProvider should display the text as es 1`] = `
-
+
@@ -14710,7 +14752,9 @@ exports[`ConfigProvider should display the text as fa-IR 1`] = `
-
+
@@ -15194,7 +15238,9 @@ exports[`ConfigProvider should display the text as fa-IR 1`] = `
-
+
@@ -15670,7 +15716,9 @@ exports[`ConfigProvider should display the text as fa-IR 1`] = `
-
+
@@ -16167,7 +16215,9 @@ exports[`ConfigProvider should display the text as fa-IR 1`] = `
-
+
@@ -16637,7 +16687,9 @@ exports[`ConfigProvider should display the text as fa-IR 1`] = `
-
+
@@ -17128,7 +17180,9 @@ exports[`ConfigProvider should display the text as fa-IR 1`] = `
-
+
@@ -17607,7 +17661,9 @@ exports[`ConfigProvider should display the text as fa-IR 1`] = `
-
+
@@ -19354,7 +19410,9 @@ exports[`ConfigProvider should display the text as fr-FR 1`] = `
-
+
@@ -19838,7 +19896,9 @@ exports[`ConfigProvider should display the text as fr-FR 1`] = `
-
+
@@ -20314,7 +20374,9 @@ exports[`ConfigProvider should display the text as fr-FR 1`] = `
-
+
@@ -20811,7 +20873,9 @@ exports[`ConfigProvider should display the text as fr-FR 1`] = `
-
+
@@ -21281,7 +21345,9 @@ exports[`ConfigProvider should display the text as fr-FR 1`] = `
-
+
@@ -21772,7 +21838,9 @@ exports[`ConfigProvider should display the text as fr-FR 1`] = `
-
+
@@ -22251,7 +22319,9 @@ exports[`ConfigProvider should display the text as fr-FR 1`] = `
-
+
@@ -23998,7 +24068,9 @@ exports[`ConfigProvider should display the text as id-ID 1`] = `
-
+
@@ -24482,7 +24554,9 @@ exports[`ConfigProvider should display the text as id-ID 1`] = `
-
+
@@ -24958,7 +25032,9 @@ exports[`ConfigProvider should display the text as id-ID 1`] = `
-
+
@@ -25455,7 +25531,9 @@ exports[`ConfigProvider should display the text as id-ID 1`] = `
-
+
@@ -25925,7 +26003,9 @@ exports[`ConfigProvider should display the text as id-ID 1`] = `
-
+
@@ -26416,7 +26496,9 @@ exports[`ConfigProvider should display the text as id-ID 1`] = `
-
+
@@ -26895,7 +26977,9 @@ exports[`ConfigProvider should display the text as id-ID 1`] = `
-
+
@@ -28642,7 +28726,9 @@ exports[`ConfigProvider should display the text as it-IT 1`] = `
-
+
@@ -29126,7 +29212,9 @@ exports[`ConfigProvider should display the text as it-IT 1`] = `
-
+
@@ -29602,7 +29690,9 @@ exports[`ConfigProvider should display the text as it-IT 1`] = `
-
+
@@ -30099,7 +30189,9 @@ exports[`ConfigProvider should display the text as it-IT 1`] = `
-
+
@@ -30569,7 +30661,9 @@ exports[`ConfigProvider should display the text as it-IT 1`] = `
-
+
@@ -31060,7 +31154,9 @@ exports[`ConfigProvider should display the text as it-IT 1`] = `
-
+
@@ -31539,7 +31635,9 @@ exports[`ConfigProvider should display the text as it-IT 1`] = `
-
+
@@ -33286,7 +33384,9 @@ exports[`ConfigProvider should display the text as ja-JP 1`] = `
-
+
@@ -33770,7 +33870,9 @@ exports[`ConfigProvider should display the text as ja-JP 1`] = `
-
+
@@ -34246,7 +34348,9 @@ exports[`ConfigProvider should display the text as ja-JP 1`] = `
-
+
@@ -34743,7 +34847,9 @@ exports[`ConfigProvider should display the text as ja-JP 1`] = `
-
+
@@ -35213,7 +35319,9 @@ exports[`ConfigProvider should display the text as ja-JP 1`] = `
-
+
@@ -35704,7 +35812,9 @@ exports[`ConfigProvider should display the text as ja-JP 1`] = `
-
+
@@ -36183,7 +36293,9 @@ exports[`ConfigProvider should display the text as ja-JP 1`] = `
-
+
@@ -37930,7 +38042,9 @@ exports[`ConfigProvider should display the text as kk-KZ 1`] = `
-
+
@@ -38414,7 +38528,9 @@ exports[`ConfigProvider should display the text as kk-KZ 1`] = `
-
+
@@ -38890,7 +39006,9 @@ exports[`ConfigProvider should display the text as kk-KZ 1`] = `
-
+
@@ -39387,7 +39505,9 @@ exports[`ConfigProvider should display the text as kk-KZ 1`] = `
-
+
@@ -39857,7 +39977,9 @@ exports[`ConfigProvider should display the text as kk-KZ 1`] = `
-
+
@@ -40348,7 +40470,9 @@ exports[`ConfigProvider should display the text as kk-KZ 1`] = `
-
+
@@ -40827,7 +40951,9 @@ exports[`ConfigProvider should display the text as kk-KZ 1`] = `
-
+
@@ -42574,7 +42700,9 @@ exports[`ConfigProvider should display the text as ko-KR 1`] = `
-
+
@@ -43058,7 +43186,9 @@ exports[`ConfigProvider should display the text as ko-KR 1`] = `
-
+
@@ -43534,7 +43664,9 @@ exports[`ConfigProvider should display the text as ko-KR 1`] = `
-
+
@@ -44031,7 +44163,9 @@ exports[`ConfigProvider should display the text as ko-KR 1`] = `
-
+
@@ -44501,7 +44635,9 @@ exports[`ConfigProvider should display the text as ko-KR 1`] = `
-
+
@@ -44992,7 +45128,9 @@ exports[`ConfigProvider should display the text as ko-KR 1`] = `
-
+
@@ -45471,7 +45609,9 @@ exports[`ConfigProvider should display the text as ko-KR 1`] = `
-
+
@@ -47218,7 +47358,9 @@ exports[`ConfigProvider should display the text as nb-NO 1`] = `
-
+
@@ -47702,7 +47844,9 @@ exports[`ConfigProvider should display the text as nb-NO 1`] = `
-
+
@@ -48178,7 +48322,9 @@ exports[`ConfigProvider should display the text as nb-NO 1`] = `
-
+
@@ -48675,7 +48821,9 @@ exports[`ConfigProvider should display the text as nb-NO 1`] = `
-
+
@@ -49145,7 +49293,9 @@ exports[`ConfigProvider should display the text as nb-NO 1`] = `
-
+
@@ -49636,7 +49786,9 @@ exports[`ConfigProvider should display the text as nb-NO 1`] = `
-
+
@@ -50115,7 +50267,9 @@ exports[`ConfigProvider should display the text as nb-NO 1`] = `
-
+
@@ -51862,7 +52016,9 @@ exports[`ConfigProvider should display the text as nl-NL 1`] = `
-
+
@@ -52346,7 +52502,9 @@ exports[`ConfigProvider should display the text as nl-NL 1`] = `
-
+
@@ -52822,7 +52980,9 @@ exports[`ConfigProvider should display the text as nl-NL 1`] = `
-
+
@@ -53319,7 +53479,9 @@ exports[`ConfigProvider should display the text as nl-NL 1`] = `
-
+
@@ -53789,7 +53951,9 @@ exports[`ConfigProvider should display the text as nl-NL 1`] = `
-
+
@@ -54280,7 +54444,9 @@ exports[`ConfigProvider should display the text as nl-NL 1`] = `
-
+
@@ -54759,7 +54925,9 @@ exports[`ConfigProvider should display the text as nl-NL 1`] = `
-
+
@@ -56506,7 +56674,9 @@ exports[`ConfigProvider should display the text as ru 1`] = `
-
+
@@ -56990,7 +57160,9 @@ exports[`ConfigProvider should display the text as ru 1`] = `
-
+
@@ -57466,7 +57638,9 @@ exports[`ConfigProvider should display the text as ru 1`] = `
-
+
@@ -57963,7 +58137,9 @@ exports[`ConfigProvider should display the text as ru 1`] = `
-
+
@@ -58433,7 +58609,9 @@ exports[`ConfigProvider should display the text as ru 1`] = `
-
+
@@ -58924,7 +59102,9 @@ exports[`ConfigProvider should display the text as ru 1`] = `
-
+
@@ -59403,7 +59583,9 @@ exports[`ConfigProvider should display the text as ru 1`] = `
-
+
@@ -61150,7 +61332,9 @@ exports[`ConfigProvider should display the text as tr-TR 1`] = `
-
+
@@ -61634,7 +61818,9 @@ exports[`ConfigProvider should display the text as tr-TR 1`] = `
-
+
@@ -62110,7 +62296,9 @@ exports[`ConfigProvider should display the text as tr-TR 1`] = `
-
+
@@ -62607,7 +62795,9 @@ exports[`ConfigProvider should display the text as tr-TR 1`] = `
-
+
@@ -63077,7 +63267,9 @@ exports[`ConfigProvider should display the text as tr-TR 1`] = `
-
+
@@ -63568,7 +63760,9 @@ exports[`ConfigProvider should display the text as tr-TR 1`] = `
-
+
@@ -64047,7 +64241,9 @@ exports[`ConfigProvider should display the text as tr-TR 1`] = `
-
+
@@ -65794,7 +65990,9 @@ exports[`ConfigProvider should display the text as zh-CH 1`] = `
-
+
@@ -66278,7 +66476,9 @@ exports[`ConfigProvider should display the text as zh-CH 1`] = `
-
+
@@ -66754,7 +66954,9 @@ exports[`ConfigProvider should display the text as zh-CH 1`] = `
-
+
@@ -67251,7 +67453,9 @@ exports[`ConfigProvider should display the text as zh-CH 1`] = `
-
+
@@ -67721,7 +67925,9 @@ exports[`ConfigProvider should display the text as zh-CH 1`] = `
-
+
@@ -68212,7 +68418,9 @@ exports[`ConfigProvider should display the text as zh-CH 1`] = `
-
+
@@ -68691,7 +68899,9 @@ exports[`ConfigProvider should display the text as zh-CH 1`] = `
-
+
@@ -70438,7 +70648,9 @@ exports[`ConfigProvider should display the text as zh-HK 1`] = `
-
+
@@ -70922,7 +71134,9 @@ exports[`ConfigProvider should display the text as zh-HK 1`] = `
-
+
@@ -71398,7 +71612,9 @@ exports[`ConfigProvider should display the text as zh-HK 1`] = `
-
+
@@ -71895,7 +72111,9 @@ exports[`ConfigProvider should display the text as zh-HK 1`] = `
-
+
@@ -72365,7 +72583,9 @@ exports[`ConfigProvider should display the text as zh-HK 1`] = `
-
+
@@ -72856,7 +73076,9 @@ exports[`ConfigProvider should display the text as zh-HK 1`] = `
-
+
@@ -73335,7 +73557,9 @@ exports[`ConfigProvider should display the text as zh-HK 1`] = `
-
+
@@ -75082,7 +75306,9 @@ exports[`ConfigProvider should display the text as zh-TW 1`] = `
-
+
@@ -75566,7 +75792,9 @@ exports[`ConfigProvider should display the text as zh-TW 1`] = `
-
+
@@ -76042,7 +76270,9 @@ exports[`ConfigProvider should display the text as zh-TW 1`] = `
-
+
@@ -76539,7 +76769,9 @@ exports[`ConfigProvider should display the text as zh-TW 1`] = `
-
+
@@ -77009,7 +77241,9 @@ exports[`ConfigProvider should display the text as zh-TW 1`] = `
-
+
@@ -77500,7 +77734,9 @@ exports[`ConfigProvider should display the text as zh-TW 1`] = `
-
+
@@ -77979,7 +78215,9 @@ exports[`ConfigProvider should display the text as zh-TW 1`] = `
-
+