@@ -442,6 +442,38 @@ describe('Core htmx AJAX headers', function() {
442442 } , 30 )
443443 } )
444444
445+ it ( 'should replace Url on HX-Location if push is false and replace is set' , function ( done ) {
446+ sessionStorage . setItem ( 'htmx-current-path-for-history' , '/old' )
447+ this . server . respondWith ( 'GET' , '/test' , [ 200 , { 'HX-Location' : '{"push":false, "replace":"true", "path":"/test2", "target":"#work-area"}' } , '' ] )
448+ this . server . respondWith ( 'GET' , '/test2' , [ 200 , { } , '<div>Yay! Welcome</div>' ] )
449+ var div = make ( '<div id="testdiv" hx-trigger="click" hx-get="/test"></div>' )
450+ div . click ( )
451+ this . server . respond ( )
452+ this . server . respond ( )
453+ setTimeout ( function ( ) {
454+ getWorkArea ( ) . innerHTML . should . equal ( '<div>Yay! Welcome</div>' )
455+ var path = sessionStorage . getItem ( 'htmx-current-path-for-history' )
456+ path . should . equal ( '/test2' )
457+ done ( )
458+ } , 30 )
459+ } )
460+
461+ it ( 'should replace Url on HX-Location if push is string false and replace is set' , function ( done ) {
462+ sessionStorage . setItem ( 'htmx-current-path-for-history' , '/old' )
463+ this . server . respondWith ( 'GET' , '/test' , [ 200 , { 'HX-Location' : '{"push":"false", "replace":"true", "path":"/test2", "target":"#work-area"}' } , '' ] )
464+ this . server . respondWith ( 'GET' , '/test2' , [ 200 , { } , '<div>Yay! Welcome</div>' ] )
465+ var div = make ( '<div id="testdiv" hx-trigger="click" hx-get="/test"></div>' )
466+ div . click ( )
467+ this . server . respond ( )
468+ this . server . respond ( )
469+ setTimeout ( function ( ) {
470+ getWorkArea ( ) . innerHTML . should . equal ( '<div>Yay! Welcome</div>' )
471+ var path = sessionStorage . getItem ( 'htmx-current-path-for-history' )
472+ path . should . equal ( '/test2' )
473+ done ( )
474+ } , 30 )
475+ } )
476+
445477 it ( 'should push different Url on HX-Location if push Url is string' , function ( done ) {
446478 sessionStorage . removeItem ( 'htmx-current-path-for-history' )
447479 var HTMX_HISTORY_CACHE_NAME = 'htmx-history-cache'
0 commit comments