jquery-mobile/tests/unit/fetchlink/fetchlink_core.js
2011-12-23 15:49:21 -05:00

88 lines
No EOL
2.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* Fetchlink unit tests
*/
(function($){
module( "Fetchlinks", {
setup: function(){
// $.testHelper.openPage("#fetchlink-test1");
}
});
asyncTest( "Clicking a fetchlink loads remote content.", function(){
var targetContents = $( '.loadinto' ).html();
$.testHelper.pageSequence([
function(){
$('.standalone').trigger('click');
},
function(){
ok( targetContents !== $( '.loadinto' ).html() );
start();
}
]);
});
asyncTest( "Clicking a grouped fetchlink loads remote content.", function(){
var targetContents = $( '.loadinto' ).html();
$.testHelper.pageSequence([
function(){
$('.bar').trigger('click');
},
function(){
ok( targetContents !== $( '.loadinto' ).html() );
start();
}
]);
});
asyncTest( "When no remote fragment is specified, the remote “page” elements contents are pulled in instead.", function(){
$.testHelper.pageSequence([
function(){
$('.remote-page').trigger('click');
},
function(){
var headerFirst = $('.loadinto').find('div:first').attr('data-nstest-role') === 'header',
footerLast = $('.loadinto').find('div:last').attr('data-nstest-role') === 'footer';
ok( headerFirst && footerLast, "First and last items within the page wrapper match the first and last items in the target container." );
start();
}
]);
});
asyncTest( "Elements are properly enhanced after being fetched.", function(){
$.testHelper.pageSequence([
function(){
ok( $('.loadinto').find('[data-nstest-role="header"]').hasClass( 'ui-header' ), "Page header is enhanced." );
ok( $('.loadinto').find('[data-nstest-role="content"]').hasClass( 'ui-content' ), "Page content is enhanced." );
ok( $('.loadinto').find('[data-nstest-role="footer"]').hasClass( 'ui-footer' ), "Page footer is enhanced." );
ok( $('.loadinto').find('[data-nstest-role="button"]').hasClass( 'ui-btn' ), "A link with a role of “button” is enhanced." );
ok( $('.loadinto').find('[data-nstest-role="slider"]').hasClass( 'ui-slider-switch' ), "Toggles are enhanced." );
ok( $('.loadinto').find('#test-slider').hasClass( 'ui-slider-input' ), "Slider widgets are enhanced." );
start();
}
]);
});
asyncTest( "Fetchlinks within remote content function normally.", function(){
var targetContents = $( '.secondtarget' ).html();
$.testHelper.pageSequence([
function() {
$('.remote-fetchlink').trigger('click');
},
function(){
ok( $('.loadinto').html() !== targetContents, "Target container has been updated with remote content." );
start();
}
]);
});
})(jQuery);