@@ -9,7 +9,7 @@ import { getDefaultConfig } from "../../configManager/config.default";
99import Config from "../../configManager/configManager" ;
1010import { PublicLogger } from "../../logger/logger" ;
1111import { ILivePreviewWindowType } from "../../types/types" ;
12- import { addLivePreviewQueryTags } from " ../../utils/addLivePreviewQueryTags" ;
12+ import { addLivePreviewQueryTags } from ' ../../utils/addLivePreviewQueryTags' ;
1313import livePreviewPostMessage from "../eventManager/livePreviewEventManager" ;
1414import { LIVE_PREVIEW_POST_MESSAGE_EVENTS } from "../eventManager/livePreviewEventManager.constant" ;
1515import {
@@ -42,6 +42,7 @@ vi.mock("../../visualBuilder/utils/visualBuilderPostMessage", async () => {
4242 } ;
4343} ) ;
4444
45+
4546Object . defineProperty ( globalThis , "crypto" , {
4647 value : {
4748 getRandomValues : ( arr : Array < any > ) => crypto . randomBytes ( arr . length ) ,
@@ -442,42 +443,31 @@ describe("incoming postMessage", () => {
442443 vi . spyOn ( window . history , "go" ) . mockImplementation ( ( ) => { } ) ;
443444
444445 // for forward
445- await livePreviewPostMessage ?. send (
446- LIVE_PREVIEW_POST_MESSAGE_EVENTS . HISTORY ,
447- {
448- type : "forward" ,
449- } as HistoryLivePreviewPostMessageEventData
450- ) ;
446+ await livePreviewPostMessage ?. send ( LIVE_PREVIEW_POST_MESSAGE_EVENTS . HISTORY , {
447+ type : "forward" ,
448+ } as HistoryLivePreviewPostMessageEventData ) ;
451449
452450 expect ( window . history . forward ) . toHaveBeenCalled ( ) ;
453451
454452 // for back
455- await livePreviewPostMessage ?. send (
456- LIVE_PREVIEW_POST_MESSAGE_EVENTS . HISTORY ,
457- {
458- type : "backward" ,
459- } as HistoryLivePreviewPostMessageEventData
460- ) ;
453+ await livePreviewPostMessage ?. send ( LIVE_PREVIEW_POST_MESSAGE_EVENTS . HISTORY , {
454+ type : "backward" ,
455+ } as HistoryLivePreviewPostMessageEventData ) ;
461456
462457 expect ( window . history . back ) . toHaveBeenCalled ( ) ;
463458
464459 // for reload
465- await livePreviewPostMessage ?. send (
466- LIVE_PREVIEW_POST_MESSAGE_EVENTS . HISTORY ,
467- {
468- type : "reload" ,
469- } as HistoryLivePreviewPostMessageEventData
470- ) ;
460+ await livePreviewPostMessage ?. send ( LIVE_PREVIEW_POST_MESSAGE_EVENTS . HISTORY , {
461+ type : "reload" ,
462+ } as HistoryLivePreviewPostMessageEventData ) ;
471463
472464 expect ( window . history . go ) . toHaveBeenCalled ( ) ;
473465 } ) ;
474466} ) ;
475467
476468describe ( "testing window event listeners" , ( ) => {
477469 let addEventListenerMock : any ;
478- const sendInitEvent = vi
479- . fn ( )
480- . mockImplementation ( mockLivePreviewInitEventListener ) ;
470+ const sendInitEvent = vi . fn ( ) . mockImplementation ( mockLivePreviewInitEventListener ) ;
481471 let livePreviewInstance : LivePreview ;
482472
483473 beforeEach ( ( ) => {
@@ -518,9 +508,7 @@ describe("testing window event listeners", () => {
518508 } ) ;
519509
520510 test ( "should attach a load event to call requestDataSync if document is not yet loaded" , ( ) => {
521- const readyState = vi
522- . spyOn ( document , "readyState" , "get" )
523- . mockReturnValue ( "loading" ) ;
511+ const readyState = vi . spyOn ( document , "readyState" , "get" ) . mockReturnValue ( "loading" ) ;
524512
525513 Config . replace ( {
526514 enable : true ,
@@ -535,6 +523,7 @@ describe("testing window event listeners", () => {
535523 readyState . mockRestore ( ) ;
536524 } ) ;
537525 test ( "should handle link click event if ssr is set to true" , async ( ) => {
526+
538527 Config . replace ( {
539528 enable : true ,
540529 ssr : true ,
@@ -546,15 +535,13 @@ describe("testing window event listeners", () => {
546535
547536 document . body . appendChild ( targetElement ) ;
548537 await act ( async ( ) => {
549- livePreviewInstance = new LivePreview ( ) ;
538+ livePreviewInstance = new LivePreview ( ) ;
550539 } ) ;
551540 await waitFor ( ( ) => {
552541 expect ( sendInitEvent ) . toBeCalled ( ) ;
553- } ) ;
542+ } )
554543 await waitFor ( ( ) => {
555- expect ( Config . get ( ) . stackDetails . contentTypeUid ) . toBe (
556- "contentTypeUid"
557- ) ;
544+ expect ( Config . get ( ) . stackDetails . contentTypeUid ) . toBe ( "contentTypeUid" ) ;
558545 } ) ;
559546 await act ( async ( ) => {
560547 fireEvent . click ( targetElement ) ;
0 commit comments