@@ -47,5 +47,42 @@ configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
4747 const datetime = page . locator ( '#display' ) ;
4848 await expect ( datetime ) . toHaveScreenshot ( screenshot ( `datetime-show-adjacent-days-display` ) ) ;
4949 } ) ;
50+
51+ test ( 'should return the same date format on current month days and on adjacent days' , async ( { page } ) => {
52+ await page . goto ( '/src/components/datetime/test/show-adjacent-days' , config ) ;
53+ await page . setContent (
54+ `
55+ <ion-datetime show-adjacent-days="true" locale="en-US" value="2022-10-14T16:22:00.000Z" presentation="date"></ion-datetime>
56+ <script>
57+ const mockToday = '2022-10-10T16:22';
58+ Date = class extends Date {
59+ constructor(...args) {
60+ if (args.length === 0) {
61+ super(mockToday)
62+ } else {
63+ super(...args);
64+ }
65+ }
66+ }
67+ </script>
68+ ` ,
69+ config
70+ ) ;
71+ await page . locator ( '.datetime-ready' ) . waitFor ( ) ;
72+ const datetime = page . locator ( 'ion-datetime' ) ;
73+ const ionChange = await page . spyOnEvent ( 'ionChange' ) ;
74+ // Oct 20, 2022
75+ await page . click ( '.calendar-day[data-month="10"][data-year="2022"][data-day="20"]' ) ;
76+ await expect ( ionChange ) . toHaveReceivedEventDetail ( { value : '2022-10-20T16:22:00' } ) ;
77+ await expect ( datetime ) . toHaveJSProperty ( 'value' , '2022-10-20T16:22:00' ) ;
78+ // Nov 1, 2022
79+ await page . click ( '.calendar-day[data-month="11"][data-year="2022"][data-day="1"]' ) ;
80+ await expect ( ionChange ) . toHaveReceivedEventDetail ( { value : '2022-11-01T16:22:00' } ) ;
81+ await expect ( datetime ) . toHaveJSProperty ( 'value' , '2022-11-01T16:22:00' ) ;
82+ // Nov 22, 2022
83+ await page . click ( '.calendar-day[data-month="11"][data-year="2022"][data-day="22"]' ) ;
84+ await expect ( ionChange ) . toHaveReceivedEventDetail ( { value : '2022-11-22T16:22:00' } ) ;
85+ await expect ( datetime ) . toHaveJSProperty ( 'value' , '2022-11-22T16:22:00' ) ;
86+ } ) ;
5087 } ) ;
5188} ) ;
0 commit comments