@@ -2,6 +2,7 @@ import { render, act, waitFor, fireEvent } from "@testing-library/react";
2
2
import { userEvent } from "@testing-library/user-event" ;
3
3
import { enUS , enGB } from "date-fns/locale" ;
4
4
import React , { useState } from "react" ;
5
+ import { OUTSIDE_CLICK_IGNORE_CLASS } from "../calendar" ;
5
6
6
7
import {
7
8
KeyType ,
@@ -687,21 +688,45 @@ describe("DatePicker", () => {
687
688
} ) ;
688
689
} ) ;
689
690
690
- it ( "should not apply the react-datepicker-ignore-onclickoutside class to the date input when closed" , ( ) => {
691
+ it ( "should not apply the default outsideClickIgnoreClass class to the date input when closed" , ( ) => {
691
692
const { container } = render ( < DatePicker /> ) ;
692
693
const input = safeQuerySelector ( container , "input" ) ;
693
- expect (
694
- input ?. classList . contains ( "react-datepicker-ignore-onclickoutside" ) ,
695
- ) . toBeFalsy ( ) ;
694
+ expect ( input ?. classList . contains ( OUTSIDE_CLICK_IGNORE_CLASS ) ) . toBe ( false ) ;
696
695
} ) ;
697
696
698
- it ( "should apply the react-datepicker-ignore-onclickoutside class to date input when open" , ( ) => {
697
+ it ( "should apply the default outsideClickIgnoreClass class to date input when open" , ( ) => {
699
698
const { container } = render ( < DatePicker /> ) ;
700
699
const input = safeQuerySelector < HTMLInputElement > ( container , "input" ) ;
701
700
fireEvent . focus ( input ) ;
702
- expect (
703
- input ?. classList . contains ( "react-datepicker-ignore-onclickoutside" ) ,
704
- ) . toBeTruthy ( ) ;
701
+ expect ( input ?. classList . contains ( OUTSIDE_CLICK_IGNORE_CLASS ) ) . toBe ( true ) ;
702
+ } ) ;
703
+
704
+ it ( "should apply the outsideClickIgnoreClass class to date input when open" , ( ) => {
705
+ const outsideClickIgnoreClass = "ignore-onclickoutside" ;
706
+ const { container } = render (
707
+ < DatePicker outsideClickIgnoreClass = { outsideClickIgnoreClass } /> ,
708
+ ) ;
709
+ const input = safeQuerySelector < HTMLInputElement > ( container , "input" ) ;
710
+ fireEvent . focus ( input ) ;
711
+ expect ( input ?. classList . contains ( outsideClickIgnoreClass ) ) . toBe ( true ) ;
712
+ } ) ;
713
+
714
+ it ( "should apply the default outsideClickIgnoreClass when prop is undefined" , ( ) => {
715
+ const { container } = render (
716
+ < DatePicker outsideClickIgnoreClass = { undefined } /> ,
717
+ ) ;
718
+ const input = safeQuerySelector < HTMLInputElement > ( container , "input" ) ;
719
+ fireEvent . focus ( input ) ;
720
+ expect ( input ?. classList . contains ( OUTSIDE_CLICK_IGNORE_CLASS ) ) . toBe ( true ) ;
721
+ } ) ;
722
+
723
+ it ( "should apply the default outsideClickIgnoreClass when prop is falsy" , ( ) => {
724
+ const { container } = render (
725
+ < DatePicker outsideClickIgnoreClass = { undefined } /> ,
726
+ ) ;
727
+ const input = safeQuerySelector < HTMLInputElement > ( container , "input" ) ;
728
+ fireEvent . focus ( input ) ;
729
+ expect ( input ?. classList . contains ( OUTSIDE_CLICK_IGNORE_CLASS ) ) . toBe ( true ) ;
705
730
} ) ;
706
731
707
732
it ( "should toggle the open status of calendar on click of the icon when toggleCalendarOnIconClick is set to true" , ( ) => {
0 commit comments