55"use strict" ; 
66
77describe ( "'createSocketURL' function " ,  ( )  =>  { 
8+   global . __webpack_hash__  =  "hash" ; 
9+ 
810  const  samples  =  [ 
9-     // __resourceQuery, location and socket URL 
11+     // //  __resourceQuery, location and socket URL 
1012    [ 
1113      "?hostname=example.com&pathname=/ws" , 
1214      "http://example.com" , 
@@ -103,16 +105,20 @@ describe("'createSocketURL' function ", () => {
103105  ] ; 
104106
105107  samples . forEach ( ( [ __resourceQuery ,  location ,  expected ] )  =>  { 
106-     jest . doMock ( 
107-       "../../../client-src/utils/getCurrentScriptSource" , 
108-       ( )  =>  ( )  =>  new  URL ( "./entry.js" ,  location ) . toString ( ) , 
109-     ) ; 
108+     test ( `should return '${ expected } ${ __resourceQuery } ${ location }  ,  ( )  =>  { 
109+       global . __resourceQuery  =  __resourceQuery ; 
110110
111-     const  createSocketURL  = 
112-       require ( "../../../client-src/utils/createSocketURL" ) . default ; 
113-     const  parseURL  =  require ( "../../../client-src/utils/parseURL" ) . default ; 
111+       if  ( __resourceQuery  ===  null )  { 
112+         Object . defineProperty ( document ,  "currentScript" ,  { 
113+           value : document . createElement ( "script" ) , 
114+           configurable : true , 
115+         } ) ; 
116+       } 
117+ 
118+       const  client  =  require ( "../../../client-src/index" ) ; 
119+       const  createSocketURL  =  client . createSocketURL ; 
120+       const  parseURL  =  client . parseURL ; 
114121
115-     test ( `should return '${ expected } ${ __resourceQuery } ${ location }  ,  ( )  =>  { 
116122      const  selfLocation  =  new  URL ( location ) ; 
117123
118124      delete  window . location ; 
@@ -121,6 +127,13 @@ describe("'createSocketURL' function ", () => {
121127
122128      const  parsedURL  =  parseURL ( __resourceQuery ) ; 
123129
130+       if  ( __resourceQuery  ===  null )  { 
131+         Object . defineProperty ( document ,  "currentScript" ,  { 
132+           value : null , 
133+           configurable : true , 
134+         } ) ; 
135+       } 
136+ 
124137      expect ( createSocketURL ( parsedURL ) ) . toBe ( expected ) ; 
125138    } ) ; 
126139
0 commit comments