@@ -110,6 +110,8 @@ describe("pat-tooltip", () => {
110110 const expected =
111111 container [ 0 ] . querySelector ( ".tippy-content" ) . textContent ;
112112 expect ( expected ) . toBe ( title ) ;
113+
114+ spy_show . mockRestore ( ) ;
113115 } ) ;
114116
115117 it ( "1.2.2 - and only to the corresponding container" , async ( ) => {
@@ -191,6 +193,9 @@ describe("pat-tooltip", () => {
191193 expect ( expected ) . toBe ( title ) ;
192194 const duration = timer [ "onShow" ] - timer [ "onTrigger" ] ;
193195 expect ( duration / 500 ) . toBeCloseTo ( 1 , 1 ) ;
196+
197+ spy_show . mockRestore ( ) ;
198+ spy_trigger . mockRestore ( ) ;
194199 } ) ;
195200 } ) ;
196201 } ) ;
@@ -225,6 +230,9 @@ describe("pat-tooltip", () => {
225230 testutils . click ( $el ) ;
226231 await utils . timeout ( 50 ) ;
227232 expect ( spy_hide ) . toHaveBeenCalled ( ) ;
233+
234+ spy_show . mockRestore ( ) ;
235+ spy_hide . mockRestore ( ) ;
228236 } ) ;
229237
230238 it ( "2.1.2 - with `trigger: hover` it will close when hovering outside the tooltip element" , async ( ) => {
@@ -239,9 +247,9 @@ describe("pat-tooltip", () => {
239247 const spy_hide = jest . spyOn ( tp , "onHide" ) ;
240248
241249 // Shortcut any checks for mouse positions and just hide.
242- jest . spyOn ( instance . tippy , "hideWithInteractivity" ) . mockImplementation (
243- instance . tippy . hide
244- ) ;
250+ const spy_inter = jest
251+ . spyOn ( instance . tippy , "hideWithInteractivity" )
252+ . mockImplementation ( instance . tippy . hide ) ;
245253
246254 testutils . mouseenter ( $el ) ;
247255 await utils . timeout ( 1 ) ;
@@ -251,6 +259,10 @@ describe("pat-tooltip", () => {
251259 testutils . mouseleave ( $el ) ;
252260 await utils . timeout ( 1 ) ;
253261 expect ( spy_hide ) . toHaveBeenCalled ( ) ;
262+
263+ spy_show . mockRestore ( ) ;
264+ spy_hide . mockRestore ( ) ;
265+ spy_inter . mockRestore ( ) ;
254266 } ) ;
255267 } ) ;
256268
@@ -283,6 +295,9 @@ describe("pat-tooltip", () => {
283295 testutils . click ( $el ) ;
284296 await utils . timeout ( 50 ) ;
285297 expect ( spy_hide ) . toHaveBeenCalled ( ) ;
298+
299+ spy_show . mockRestore ( ) ;
300+ spy_hide . mockRestore ( ) ;
286301 } ) ;
287302
288303 it ( "2.2.2 - with `trigger: hover` the tooltip is only closed when clicking outside" , async ( ) => {
@@ -308,6 +323,9 @@ describe("pat-tooltip", () => {
308323 testutils . click ( $el ) ;
309324 await utils . timeout ( 50 ) ;
310325 expect ( spy_hide ) . toHaveBeenCalled ( ) ;
326+
327+ spy_show . mockRestore ( ) ;
328+ spy_hide . mockRestore ( ) ;
311329 } ) ;
312330 } ) ;
313331
@@ -346,6 +364,9 @@ describe("pat-tooltip", () => {
346364 closebutton . click ( ) ;
347365 await utils . timeout ( 50 ) ;
348366 expect ( spy_hide ) . toHaveBeenCalled ( ) ;
367+
368+ spy_show . mockRestore ( ) ;
369+ spy_hide . mockRestore ( ) ;
349370 } ) ;
350371
351372 it ( "2.3.2 - with `trigger: hover` the tooltip is only closed when clicking outside" , async ( ) => {
@@ -376,6 +397,9 @@ describe("pat-tooltip", () => {
376397 closebutton . click ( ) ;
377398 await utils . timeout ( 50 ) ;
378399 expect ( spy_hide ) . toHaveBeenCalled ( ) ;
400+
401+ spy_show . mockRestore ( ) ;
402+ spy_hide . mockRestore ( ) ;
379403 } ) ;
380404
381405 it ( "2.3.3 - a close-panel doesn't prevent a form submit." , async ( ) => {
@@ -463,6 +487,9 @@ describe("pat-tooltip", () => {
463487 expect ( container [ 1 ] . querySelector ( ".tippy-content" ) . textContent ) . toBe (
464488 title2
465489 ) ;
490+
491+ spy_show1 . mockRestore ( ) ;
492+ spy_show2 . mockRestore ( ) ;
466493 } ) ;
467494 } ) ;
468495
@@ -666,6 +693,9 @@ describe("pat-tooltip", () => {
666693 //expect(containers.length).toEqual(0);
667694 expect ( el . classList . contains ( "tooltip-active-click" ) ) . toBeFalsy ( ) ;
668695 expect ( el . classList . contains ( "tooltip-inactive" ) ) . toBeTruthy ( ) ;
696+
697+ spy_show . mockRestore ( ) ;
698+ spy_hide . mockRestore ( ) ;
669699 } ) ;
670700 it ( "5.1.2 - when false, the trigger does not get the active/inactive class" , async ( ) => {
671701 const $el = testutils . createTooltip ( {
@@ -704,6 +734,9 @@ describe("pat-tooltip", () => {
704734 //expect(containers.length).toEqual(0);
705735 expect ( el . classList . contains ( "tooltip-active-click" ) ) . toBeFalsy ( ) ;
706736 expect ( el . classList . contains ( "tooltip-inactive" ) ) . toBeFalsy ( ) ;
737+
738+ spy_show . mockRestore ( ) ;
739+ spy_hide . mockRestore ( ) ;
707740 } ) ;
708741 it ( "5.1.3 - when true and trigger is hover, toggles a different active class on the trigger" , async ( ) => {
709742 const $el = testutils . createTooltip ( {
@@ -728,6 +761,8 @@ describe("pat-tooltip", () => {
728761 expect ( containers . length ) . toEqual ( 1 ) ;
729762 expect ( el . classList . contains ( "tooltip-active-hover" ) ) . toBeTruthy ( ) ;
730763 expect ( el . classList . contains ( "tooltip-inactive" ) ) . toBeFalsy ( ) ;
764+
765+ spy_show . mockRestore ( ) ;
731766 } ) ;
732767 } ) ;
733768 describe ( `5.2 - if the 'trigger' parameter is 'hover'` , ( ) => {
@@ -758,6 +793,8 @@ describe("pat-tooltip", () => {
758793 expect (
759794 container [ 0 ] . querySelector ( ".tippy-content" ) . textContent
760795 ) . toBe ( title ) ;
796+
797+ spy_show . mockRestore ( ) ;
761798 } ) ;
762799 it ( "5.2.1.2 - will hide the tooltip on mouseleave" , async ( ) => {
763800 const $el = testutils . createTooltip ( {
@@ -770,10 +807,9 @@ describe("pat-tooltip", () => {
770807 const spy_hide = jest . spyOn ( instance . tippy . props , "onHide" ) ;
771808
772809 // Shortcut any checks for mouse positions and just hide.
773- jest . spyOn (
774- instance . tippy ,
775- "hideWithInteractivity"
776- ) . mockImplementation ( instance . tippy . hide ) ;
810+ const spy_inter = jest
811+ . spyOn ( instance . tippy , "hideWithInteractivity" )
812+ . mockImplementation ( instance . tippy . hide ) ;
777813
778814 testutils . mouseenter ( $el ) ;
779815 await utils . timeout ( 1 ) ;
@@ -784,6 +820,9 @@ describe("pat-tooltip", () => {
784820 await utils . timeout ( 1 ) ;
785821 expect ( spy_hide ) . toHaveBeenCalled ( ) ;
786822 expect ( document . querySelectorAll ( ".tippy-box" ) . length ) . toEqual ( 0 ) ;
823+
824+ spy_hide . mockRestore ( ) ;
825+ spy_inter . mockRestore ( ) ;
787826 } ) ;
788827 } ) ;
789828 describe ( `5.2.2 - if the 'source' parameter is 'content'` , ( ) => {
@@ -806,6 +845,8 @@ describe("pat-tooltip", () => {
806845 expect ( document . querySelector ( ".tippy-box" ) . textContent ) . toBe (
807846 content
808847 ) ;
848+
849+ spy_show . mockRestore ( ) ;
809850 } ) ;
810851 } ) ;
811852 } ) ;
@@ -996,7 +1037,9 @@ describe("pat-tooltip", () => {
9961037 "External content fetched via an HTTP request."
9971038 ) ;
9981039
999- global . fetch . mockClear ( ) ;
1040+ spy_content . mockRestore ( ) ;
1041+ spy_show . mockRestore ( ) ;
1042+ global . fetch . mockRestore ( ) ;
10001043 delete global . fetch ;
10011044 } ) ;
10021045
@@ -1027,7 +1070,9 @@ describe("pat-tooltip", () => {
10271070 document . querySelector ( ".tippy-box .tippy-content .pat-tooltip" )
10281071 ) . toBeTruthy ( ) ;
10291072
1030- global . fetch . mockClear ( ) ;
1073+ spy_content . mockRestore ( ) ;
1074+ spy_show . mockRestore ( ) ;
1075+ global . fetch . mockRestore ( ) ;
10311076 delete global . fetch ;
10321077 } ) ;
10331078
@@ -1068,7 +1113,9 @@ describe("pat-tooltip", () => {
10681113 "External content fetched via an HTTP request."
10691114 ) ;
10701115
1071- global . fetch . mockClear ( ) ;
1116+ spy_content . mockRestore ( ) ;
1117+ spy_show . mockRestore ( ) ;
1118+ global . fetch . mockRestore ( ) ;
10721119 delete global . fetch ;
10731120 } ) ;
10741121
@@ -1110,7 +1157,9 @@ describe("pat-tooltip", () => {
11101157 "hello."
11111158 ) ;
11121159
1113- global . fetch . mockClear ( ) ;
1160+ spy_content . mockRestore ( ) ;
1161+ spy_show . mockRestore ( ) ;
1162+ global . fetch . mockRestore ( ) ;
11141163 delete global . fetch ;
11151164 } ) ;
11161165 } ) ;
@@ -1130,12 +1179,12 @@ describe("pat-tooltip", () => {
11301179
11311180 const call_order = [ ] ;
11321181
1133- jest . spyOn ( click , "preventDefault" ) . mockImplementation ( ( ) =>
1134- call_order . push ( "preventDefault" )
1135- ) ;
1136- jest . spyOn ( instance , "_getContent" ) . mockImplementation ( ( ) =>
1137- call_order . push ( "_getContent" )
1138- ) ;
1182+ const spy_prevent = jest
1183+ . spyOn ( click , "preventDefault" )
1184+ . mockImplementation ( ( ) => call_order . push ( "preventDefault" ) ) ;
1185+ const spy_get_content = jest
1186+ . spyOn ( instance , "_getContent" )
1187+ . mockImplementation ( ( ) => call_order . push ( "_getContent" ) ) ;
11391188
11401189 $el [ 0 ] . dispatchEvent ( click ) ;
11411190 await utils . timeout ( 1 ) ; // wait a tick for async fetch
@@ -1147,7 +1196,9 @@ describe("pat-tooltip", () => {
11471196 expect ( call_order . filter ( it => it === "_getContent" ) . length ) . toEqual ( 1 ) ; // prettier-ignore
11481197 expect ( call_order . filter ( it => it === "preventDefault" ) . length ) . toEqual ( 3 ) ; // prettier-ignore
11491198
1150- global . fetch . mockClear ( ) ;
1199+ spy_prevent . mockRestore ( ) ;
1200+ spy_get_content . mockRestore ( ) ;
1201+ global . fetch . mockRestore ( ) ;
11511202 delete global . fetch ;
11521203 } ) ;
11531204
@@ -1178,7 +1229,9 @@ describe("pat-tooltip", () => {
11781229 "this will be extracted"
11791230 ) ;
11801231
1181- global . fetch . mockClear ( ) ;
1232+ spy_ajax . mockRestore ( ) ;
1233+ spy_show . mockRestore ( ) ;
1234+ global . fetch . mockRestore ( ) ;
11821235 delete global . fetch ;
11831236 } ) ;
11841237
@@ -1204,7 +1257,9 @@ describe("pat-tooltip", () => {
12041257 expect ( content ) . toBeTruthy ( ) ;
12051258 expect ( content . textContent ) . toBe ( "hello." ) ;
12061259
1207- global . fetch . mockClear ( ) ;
1260+ spy_ajax . mockRestore ( ) ;
1261+ spy_show . mockRestore ( ) ;
1262+ global . fetch . mockRestore ( ) ;
12081263 delete global . fetch ;
12091264 } ) ;
12101265
@@ -1244,7 +1299,9 @@ this will be extracted.
12441299 "this will be extracted."
12451300 ) ;
12461301
1247- global . fetch . mockClear ( ) ;
1302+ spy_ajax . mockRestore ( ) ;
1303+ spy_show . mockRestore ( ) ;
1304+ global . fetch . mockRestore ( ) ;
12481305 delete global . fetch ;
12491306 } ) ;
12501307
@@ -1287,7 +1344,10 @@ this will be extracted.
12871344 document . querySelector ( ".tippy-box .tippy-content" ) . textContent
12881345 ) . toBe ( "External content fetched via an HTTP request." ) ;
12891346
1290- global . fetch . mockClear ( ) ;
1347+ spy_show . mockRestore ( ) ;
1348+ spy_ajax . mockRestore ( ) ;
1349+ spy_fetch . mockRestore ( ) ;
1350+ global . fetch . mockRestore ( ) ;
12911351 delete global . fetch ;
12921352 } ) ;
12931353
@@ -1329,7 +1389,10 @@ this will be extracted.
13291389 document . querySelector ( ".tippy-box .tippy-content" ) . textContent
13301390 ) . toBe ( "External content fetched via an HTTP request." ) ;
13311391
1332- global . fetch . mockClear ( ) ;
1392+ spy_show . mockRestore ( ) ;
1393+ spy_ajax . mockRestore ( ) ;
1394+ spy_fetch . mockRestore ( ) ;
1395+ global . fetch . mockRestore ( ) ;
13331396 delete global . fetch ;
13341397 } ) ;
13351398 } ) ;
@@ -1357,7 +1420,7 @@ this will be extracted.
13571420
13581421 expect ( called ) . toBeTruthy ( ) ;
13591422
1360- global . fetch . mockClear ( ) ;
1423+ global . fetch . mockRestore ( ) ;
13611424 delete global . fetch ;
13621425 } ) ;
13631426
@@ -1394,7 +1457,9 @@ this will be extracted.
13941457 expect ( spy_handler1 ) . toHaveBeenCalled ( ) ;
13951458 expect ( spy_handler2 ) . toHaveBeenCalled ( ) ;
13961459
1397- global . fetch . mockClear ( ) ;
1460+ spy_handler1 . mockRestore ( ) ;
1461+ spy_handler2 . mockRestore ( ) ;
1462+ global . fetch . mockRestore ( ) ;
13981463 delete global . fetch ;
13991464 } ) ;
14001465
@@ -1413,6 +1478,8 @@ this will be extracted.
14131478 // Test, if registry.scan isn't invoked twice - another time by
14141479 // pat-inject.
14151480 expect ( spy_scan ) . toHaveBeenCalledTimes ( 1 ) ;
1481+
1482+ spy_scan . mockRestore ( ) ;
14161483 } ) ;
14171484 } ) ;
14181485
0 commit comments