@@ -227,15 +227,21 @@ describe("2 - Navigation pattern tests - mark after navigation injection", funct
227227
228228describe ( "3 - Navigation pattern tests - Mark items based on URL" , ( ) => {
229229 let _window_location ;
230+ let _originalBaseUrl ;
230231
231232 beforeEach ( ( ) => {
232233 _window_location = global . window . location ;
233234 delete global . window . location ;
234235 document . body . innerHTML = "" ;
236+ _originalBaseUrl = Pattern . prototype . base_url ;
237+ Pattern . prototype . base_url = function ( ) {
238+ return "https://patternslib.com/" ;
239+ } ;
235240 } ) ;
236241
237242 afterEach ( ( ) => {
238243 global . window . location = _window_location ;
244+ Pattern . prototype . base_url = _originalBaseUrl ;
239245 } ) ;
240246
241247 it ( "navigation roundtrip" , async ( ) => {
@@ -281,12 +287,6 @@ describe("3 - Navigation pattern tests - Mark items based on URL", () => {
281287 </nav>
282288 ` ;
283289
284- // Mock the base_url method at the prototype level to avoid JSDOM navigation issues
285- const originalBaseUrl = Pattern . prototype . base_url ;
286- Pattern . prototype . base_url = function ( ) {
287- return "https://patternslib.com/" ;
288- } ;
289-
290290 // Set portal URL directly on document body
291291 document . body . dataset . portalUrl = "https://patternslib.com" ;
292292
@@ -372,9 +372,6 @@ describe("3 - Navigation pattern tests - Mark items based on URL", () => {
372372 expect ( document . querySelectorAll ( ".current" ) . length ) . toBe ( 2 ) ;
373373 expect ( document . querySelectorAll ( ".inPath" ) . length ) . toBe ( 0 ) ;
374374 expect ( document . querySelector ( ".current a" ) ) . toBe ( it4 ) ;
375-
376- // Restore the original method
377- Pattern . prototype . base_url = originalBaseUrl ;
378375 } ) ;
379376} ) ;
380377
0 commit comments