From a2834bb36750a5720d45f880b2451f3ab8888aad Mon Sep 17 00:00:00 2001 From: John Bender Date: Sat, 21 May 2011 23:36:06 -0700 Subject: [PATCH] removed two unnecessary tests from the navigation suite, and moved a few more over to the pageSequence helper. --- tests/unit/navigation/navigation_core.js | 84 +++++++---------------- tests/unit/navigation/navigation_paths.js | 3 - 2 files changed, 26 insertions(+), 61 deletions(-) diff --git a/tests/unit/navigation/navigation_core.js b/tests/unit/navigation/navigation_core.js index 0e49571a..01ca1dea 100644 --- a/tests/unit/navigation/navigation_core.js +++ b/tests/unit/navigation/navigation_core.js @@ -15,48 +15,6 @@ } }); - asyncTest( "changepage runs once when called with an element", function(){ - var called = 0, - newChangePage = function(a,b,c,d,e){ - changePageFn( a,b,c,d,e ); - called ++; - }; - - $.testHelper.sequence([ - // avoid initial page load triggering changePage early - function(){ - $.mobile.changePage = newChangePage; - newChangePage($("#bar")); - }, - - function(){ - ok(called == 1, "change page should be called once"); - $.mobile.changePage = changePageFn; - start(); - }], 500); - }); - - asyncTest( "changepage runs twice when triggered by a link", function(){ - var called = 0, - newChangePage = function(a,b,c,d,e){ - changePageFn( a,b,c,d,e ); - called ++; - }; - - $.testHelper.sequence([ - // avoid initial page load triggering changePage early - function(){ - $.mobile.changePage = newChangePage; - $('#foo a').click(); - }, - - function(){ - ok(called == 2, "change page should be called twice"); - $.mobile.changePage = changePageFn; - start(); - }], 500); - }); - asyncTest( "forms with data attribute ajax set to false will not call changePage", function(){ var called = false; var newChangePage = function(){ @@ -306,9 +264,11 @@ }); asyncTest( "Page title updates properly when clicking back to previous page", function(){ - $.testHelper.openPage("#relative-after-embeded-page-first"); + $.testHelper.pageSequence([ + function(){ + $.testHelper.openPage("#relative-after-embeded-page-first"); + }, - $.testHelper.sequence([ function(){ window.history.back(); }, @@ -317,13 +277,15 @@ same(document.title, "jQuery Mobile Navigation Test Suite"); start(); } - ], 500); + ]); }); asyncTest( "Page title updates properly from title tag when loading an external page", function(){ - $.testHelper.openPage("#ajax-title-page"); + $.testHelper.pageSequence([ + function(){ + $.testHelper.openPage("#ajax-title-page"); + }, - $.testHelper.sequence([ function(){ $("#titletest1").click(); }, @@ -332,12 +294,15 @@ same(document.title, "Title Tag"); start(); } - ], 500); + ]); }); asyncTest( "Page title updates properly from data-title attr when loading an external page", function(){ - $.testHelper.openPage("#ajax-title-page"); - $.testHelper.sequence([ + $.testHelper.pageSequence([ + function(){ + $.testHelper.openPage("#ajax-title-page"); + }, + function(){ $("#titletest2").click(); }, @@ -346,7 +311,7 @@ same(document.title, "Title Attr"); start(); } - ], 500); + ]); }); asyncTest( "Page title updates properly from heading text in header when loading an external page", function(){ @@ -364,8 +329,11 @@ }); asyncTest( "Page links to the current active page result in the same active page", function(){ - $.testHelper.openPage("#self-link"); - $.testHelper.sequence([ + $.testHelper.pageSequence([ + function(){ + $.testHelper.openPage("#self-link"); + }, + function(){ $("a[href='#self-link']").click(); }, @@ -374,11 +342,11 @@ same($.mobile.activePage[0], $("#self-link")[0], "self-link page is still the active page" ); start(); } - ], 500); + ]); }); - asyncTest( "links on subdirectory pages with query params use an absolute path", function(){ - $.testHelper.sequence([ + asyncTest( "links on subdirectory pages with query params append the params and load the page", function(){ + $.testHelper.pageSequence([ function(){ $.testHelper.openPage("#data-url-tests/non-data-url.html"); }, @@ -389,10 +357,10 @@ function(){ same(location.hash, "#data-url-tests/non-data-url.html?foo=bar"); - ok($(".ui-page-active").jqmData("url").indexOf("?foo=bar") > -1, "the query params are in the hash"); + ok($(".ui-page-active").jqmData("url").indexOf("?foo=bar") > -1, "the query params are in the data url"); start(); } - ], 1000); + ]); }); asyncTest( "identical query param link doesn't add additional set of query params", function(){ diff --git a/tests/unit/navigation/navigation_paths.js b/tests/unit/navigation/navigation_paths.js index 47432a8a..eca8a54e 100644 --- a/tests/unit/navigation/navigation_paths.js +++ b/tests/unit/navigation/navigation_paths.js @@ -5,9 +5,6 @@ var testPageLoad = function(testPageAnchorSelector, expectedTextValue){ expect( 2 ); - // remove cached pages to make sure the page request hits the test - $(".ui-page > .test-value").parents(".ui-page").remove(); - $.testHelper.pageSequence([ // open our test page function(){