Skip to content

Commit dec5b48

Browse files
committed
Tabs tests: Work around IE quirks.
1 parent 96510ea commit dec5b48

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

tests/unit/tabs/tabs_deprecated.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,15 @@ test( "select", function() {
394394
module( "tabs (deprecated): methods" );
395395

396396
test( "add", function() {
397-
expect( 27 );
397+
expect( 28 );
398398

399399
var tab, anchor,
400400
element = $( "#tabs1" ).tabs();
401+
402+
function stripLeadingSlash( str ) {
403+
return str.substr( str.charAt( 0 ) === "/" ? 1 : 0 );
404+
}
405+
401406
state( element, 1, 0, 0 );
402407

403408
// add without index
@@ -411,7 +416,8 @@ test( "add", function() {
411416
tab = element.find( ".ui-tabs-nav li" ).last();
412417
anchor = tab.find( "a" );
413418
equal( tab.text(), "New", "label" );
414-
equal( anchor.attr( "href" ), "#new", "href" );
419+
equal( stripLeadingSlash( anchor[0].pathname ), stripLeadingSlash( location.pathname ), "href pathname" );
420+
equal( anchor[0].hash, "#new", "href hash" );
415421
equal( anchor.attr( "aria-controls" ), "new", "aria-controls" );
416422
ok( !tab.hasClass( "ui-state-hover" ), "not hovered" );
417423
anchor.simulate( "mouseover" );
@@ -430,7 +436,9 @@ test( "add", function() {
430436
tab = element.find( ".ui-tabs-nav li" ).eq( 1 );
431437
anchor = tab.find( "a" );
432438
equal( tab.text(), "New Remote", "label" );
433-
equal( anchor.attr( "href" ), "data/test.html", "href" );
439+
equal( stripLeadingSlash( stripLeadingSlash(
440+
anchor[0].pathname.replace( stripLeadingSlash( location.pathname ).split( "/" ).slice( 0, -1 ).join( "/" ), "" )
441+
) ), "data/test.html", "href" );
434442
ok( /^ui-tabs-\d+$/.test( anchor.attr( "aria-controls" ) ), "aria controls" );
435443
ok( !tab.hasClass( "ui-state-hover" ), "not hovered" );
436444
anchor.simulate( "mouseover" );
@@ -573,6 +581,10 @@ asyncTest( "abort", function() {
573581
start();
574582
});
575583
});
584+
// prevent IE from caching the request, so that it won't resolve before we call abort
585+
element.find( ".ui-tabs-nav li:eq(2) a" ).attr( "href", function( href ) {
586+
return href + "?" + (+ new Date());
587+
});
576588
element.tabs( "option", "active", 2 );
577589
element.tabs( "abort" );
578590
});

0 commit comments

Comments
 (0)