From 4d4c7653250772e16d69a7a166199c6ad8198dbd Mon Sep 17 00:00:00 2001 From: Mat Marquis Date: Fri, 23 Dec 2011 15:49:21 -0500 Subject: [PATCH] Additional fetchlink tests. --- tests/unit/fetchlink/ext-3.html | 6 ++- tests/unit/fetchlink/ext-4.html | 17 +++++++++ tests/unit/fetchlink/fetchlink_core.js | 51 ++++++++++++++++++++------ tests/unit/fetchlink/index.html | 6 ++- 4 files changed, 64 insertions(+), 16 deletions(-) create mode 100644 tests/unit/fetchlink/ext-4.html diff --git a/tests/unit/fetchlink/ext-3.html b/tests/unit/fetchlink/ext-3.html index 7f38b4a5..5e74c4e9 100644 --- a/tests/unit/fetchlink/ext-3.html +++ b/tests/unit/fetchlink/ext-3.html @@ -22,7 +22,7 @@
- Quote 1 + Quote 4 - +
+ +

Footer

diff --git a/tests/unit/fetchlink/ext-4.html b/tests/unit/fetchlink/ext-4.html new file mode 100644 index 00000000..ba781e9b --- /dev/null +++ b/tests/unit/fetchlink/ext-4.html @@ -0,0 +1,17 @@ + + + + + + jQuery Mobile Event Test Suite + + + +
+

It was easier to know it than to explain why I know it. If you were asked to prove that two and two made four, you might find some difficulty, and yet you are quite sure of the fact.

+
Arthur Conan Doyle
+ Sherlock Holmes: A Study In Scarlet +
+ + + diff --git a/tests/unit/fetchlink/fetchlink_core.js b/tests/unit/fetchlink/fetchlink_core.js index 788432e2..dd01d8a0 100644 --- a/tests/unit/fetchlink/fetchlink_core.js +++ b/tests/unit/fetchlink/fetchlink_core.js @@ -6,7 +6,7 @@ module( "Fetchlinks", { setup: function(){ - // + // $.testHelper.openPage("#fetchlink-test1"); } }); @@ -15,7 +15,7 @@ $.testHelper.pageSequence([ function(){ - $('.foo').trigger('click'); + $('.standalone').trigger('click'); }, function(){ ok( targetContents !== $( '.loadinto' ).html() ); @@ -24,7 +24,7 @@ ]); }); - asyncTest( "Clicking a fetchlink replaces previously loaded content with remote content.", function(){ + asyncTest( "Clicking a grouped fetchlink loads remote content.", function(){ var targetContents = $( '.loadinto' ).html(); $.testHelper.pageSequence([ @@ -38,24 +38,51 @@ ]); }); + asyncTest( "When no remote fragment is specified, the remote “page” element’s 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(){ - $('.baz').trigger('click'); - }, - function(){ - ok( $('[data-nstest-role="header"]').hasClass( 'ui-header' ), "Page header is enhanced." ); - ok( $('[data-nstest-role="content"]').hasClass( 'ui-content' ), "Page content is enhanced." ); - ok( $('[data-nstest-role="footer"]').hasClass( 'ui-footer' ), "Page footer is enhanced." ); - ok( $('[data-nstest-role="button"]').hasClass( 'ui-btn' ), "A link with a role of “button” is enhanced." ); - ok( $('[data-nstest-role="slider"]').hasClass( 'ui-slider-switch' ), "Toggles are enhanced." ); - ok( $('#test-slider').hasClass( 'ui-slider-input' ), "Slider widgets are enhanced." ); + 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); \ No newline at end of file diff --git a/tests/unit/fetchlink/index.html b/tests/unit/fetchlink/index.html index 9397ddd6..3e96760e 100644 --- a/tests/unit/fetchlink/index.html +++ b/tests/unit/fetchlink/index.html @@ -31,12 +31,14 @@