@@ -2,6 +2,7 @@ import { render, act, waitFor, fireEvent } from "@testing-library/react";
22import { userEvent } from "@testing-library/user-event" ;
33import { enUS , enGB } from "date-fns/locale" ;
44import React , { useState } from "react" ;
5+ import { OUTSIDE_CLICK_IGNORE_CLASS } from "../calendar" ;
56
67import {
78 KeyType ,
@@ -687,21 +688,45 @@ describe("DatePicker", () => {
687688 } ) ;
688689 } ) ;
689690
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" , ( ) => {
691692 const { container } = render ( < DatePicker /> ) ;
692693 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 ) ;
696695 } ) ;
697696
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" , ( ) => {
699698 const { container } = render ( < DatePicker /> ) ;
700699 const input = safeQuerySelector < HTMLInputElement > ( container , "input" ) ;
701700 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 ) ;
705730 } ) ;
706731
707732 it ( "should toggle the open status of calendar on click of the icon when toggleCalendarOnIconClick is set to true" , ( ) => {
0 commit comments