@@ -3,7 +3,7 @@ import { render } from '@testing-library/react'
3
3
import { renderHook } from '@testing-library/react-hooks'
4
4
import React from 'react'
5
5
import { SupportedCalendar } from '../types'
6
- import { formatDate } from '../utils'
6
+ import { convertToIso8601 , formatDate } from '../utils'
7
7
import localisationHelpers from '../utils/localisationHelpers'
8
8
import { useDatePicker , UseDatePickerReturn } from './useDatePicker'
9
9
@@ -510,34 +510,21 @@ describe('clicking a day', () => {
510
510
}
511
511
it ( 'should call the callback with correct info for Gregorian calendar' , ( ) => {
512
512
const date = '2018-01-22'
513
- const { calendarDate , calendarDateString } = renderForClick ( {
513
+ const { calendarDateString } = renderForClick ( {
514
514
calendar : 'gregory' ,
515
515
date,
516
516
} )
517
- expect ( calendarDate . toString ( ) ) . toEqual (
518
- '2018-01-22T00:00:00+02:00[Africa/Khartoum][u-ca=gregory]'
519
- )
520
517
expect ( calendarDateString ) . toEqual ( '2018-01-22' )
521
518
} )
522
519
it ( 'should call the callback with correct info for Ethiopic calendar' , ( ) => {
523
520
const date = '2015-13-02'
524
- const { calendarDate , calendarDateString } = renderForClick ( {
521
+ const { calendarDateString } = renderForClick ( {
525
522
calendar : 'ethiopic' ,
526
523
date,
527
524
} )
528
525
expect ( calendarDateString ) . toEqual ( '2015-13-02' )
529
- expect (
530
- calendarDate . withCalendar ( 'iso8601' ) . toLocaleString ( 'en-GB' )
531
- ) . toMatch ( '07/09/2023' )
532
-
533
- expect (
534
- calendarDate . toLocaleString ( 'en-GB' , {
535
- month : 'long' ,
536
- year : 'numeric' ,
537
- day : 'numeric' ,
538
- calendar : 'ethiopic' ,
539
- } )
540
- ) . toEqual ( '2 Pagumen 2015 ERA1' )
526
+ const calendarDate = convertToIso8601 ( calendarDateString , 'ethiopic' )
527
+ expect ( calendarDate ) . toEqual ( { day : 7 , month : 9 , year : 2023 } )
541
528
} )
542
529
it ( 'should call the callback with correct info for a custom (Nepali) calendar' , ( ) => {
543
530
const date = '2077-12-30'
@@ -548,7 +535,11 @@ describe('clicking a day', () => {
548
535
expect ( calendarDateString ) . toEqual ( '2077-12-30' )
549
536
expect (
550
537
localisationHelpers . localiseMonth (
551
- calendarDate ,
538
+ {
539
+ year : 20777 ,
540
+ month : 12 ,
541
+ day : 30 ,
542
+ } ,
552
543
{
553
544
locale : 'en-NP' ,
554
545
calendar : 'nepali' ,
0 commit comments