@@ -48,15 +48,27 @@ describe('useTooltip', () => {
4848 action = useTooltip ( target , options )
4949 await fireEvent . mouseOver ( target ) // fireEvent.mouseEnter only works if mouseOver is triggered before
5050 await fireEvent . mouseEnter ( target )
51- expect ( template ) . toBeVisible ( )
51+ expect ( template ) . toBeInTheDocument ( )
5252 } )
5353
5454 it ( 'Hides tooltip on mouse leave' , async ( ) => {
5555 action = useTooltip ( target , options )
5656 await fireEvent . mouseOver ( target ) // fireEvent.mouseEnter only works if mouseOver is triggered before
5757 await fireEvent . mouseEnter ( target )
5858 await fireEvent . mouseLeave ( target )
59- expect ( template ) . not . toBeVisible ( )
59+ expect ( template ) . not . toBeInTheDocument ( )
60+ await fireEvent . animationEnd ( template . parentNode )
61+ expect ( template ) . not . toBeInTheDocument ( )
62+ } )
63+
64+ it ( 'Hides tooltip on mouse leave when animated' , async ( ) => {
65+ action = useTooltip ( target , { ...options , animated : true } )
66+ await fireEvent . mouseOver ( target ) // fireEvent.mouseEnter only works if mouseOver is triggered before
67+ await fireEvent . mouseEnter ( target )
68+ await fireEvent . mouseLeave ( target )
69+ expect ( template ) . toBeInTheDocument ( )
70+ await fireEvent . animationEnd ( template . parentNode )
71+ expect ( template ) . not . toBeInTheDocument ( )
6072 } )
6173 } )
6274
@@ -70,7 +82,7 @@ describe('useTooltip', () => {
7082 const newTemplate = _createElement ( 'new-template' )
7183 action . update ( {
7284 ...options ,
73- contentSelector : '#new-template'
85+ contentSelector : '#new-template' ,
7486 } )
7587 await fireEvent . mouseOver ( target ) // fireEvent.mouseEnter only works if mouseOver is triggered before
7688 await fireEvent . mouseEnter ( target )
@@ -97,9 +109,9 @@ describe('useTooltip', () => {
97109 await fireEvent . mouseEnter ( target )
98110 await fireEvent . click ( template )
99111 expect ( contentAction . callback ) . toHaveBeenCalledWith ( contentAction . callbackParams [ 0 ] , expect . any ( Event ) )
100- expect ( template ) . toBeVisible ( )
112+ expect ( template ) . toBeInTheDocument ( )
101113 } )
102-
114+
103115 it ( 'Closes tooltip after triggering callback' , async ( ) => {
104116 action = useTooltip ( target , options )
105117 options . contentActions [ '*' ] . closeOnCallback = true
@@ -108,7 +120,22 @@ describe('useTooltip', () => {
108120 await fireEvent . mouseEnter ( target )
109121 await fireEvent . click ( template )
110122 expect ( contentAction . callback ) . toHaveBeenCalledWith ( contentAction . callbackParams [ 0 ] , expect . any ( Event ) )
111- expect ( template ) . not . toBeVisible ( )
123+ expect ( template ) . not . toBeInTheDocument ( )
124+ await fireEvent . animationEnd ( template . parentNode )
125+ expect ( template ) . not . toBeInTheDocument ( )
126+ } )
127+
128+ it ( 'Closes tooltip after triggering callback when animated' , async ( ) => {
129+ action = useTooltip ( target , { ...options , animated : true } )
130+ options . contentActions [ '*' ] . closeOnCallback = true
131+ const contentAction = options . contentActions [ '*' ]
132+ await fireEvent . mouseOver ( target ) // fireEvent.mouseEnter only works if mouseOver is triggered before
133+ await fireEvent . mouseEnter ( target )
134+ await fireEvent . click ( template )
135+ expect ( contentAction . callback ) . toHaveBeenCalledWith ( contentAction . callbackParams [ 0 ] , expect . any ( Event ) )
136+ expect ( template ) . toBeInTheDocument ( )
137+ await fireEvent . animationEnd ( template . parentNode )
138+ expect ( template ) . not . toBeInTheDocument ( )
112139 } )
113140
114141 it ( 'Triggers new callback on tooltip click after update' , async ( ) => {
@@ -142,14 +169,14 @@ describe('useTooltip', () => {
142169 action = useTooltip ( target , options )
143170 await fireEvent . mouseOver ( target ) // fireEvent.mouseEnter only works if mouseOver is triggered before
144171 await fireEvent . mouseEnter ( target )
145- expect ( template . parentNode ) . toHaveClass ( '__tooltip__default ' )
172+ expect ( template . parentNode ) . toHaveClass ( '__tooltip ' )
146173 } )
147174
148175 it ( 'Sets new tooltip class after update' , async ( ) => {
149176 action = useTooltip ( target , options )
150177 await fireEvent . mouseOver ( target ) // fireEvent.mouseEnter only works if mouseOver is triggered before
151178 await fireEvent . mouseEnter ( target )
152- expect ( template . parentNode ) . toHaveClass ( '__tooltip__default ' )
179+ expect ( template . parentNode ) . toHaveClass ( '__tooltip ' )
153180 action . update ( {
154181 ...options ,
155182 contentClassName : 'foo' ,
0 commit comments