From 5e87e8481dcdfec73074c4d6c7e8dde2b56e294c Mon Sep 17 00:00:00 2001 From: Kin Blas Date: Mon, 23 May 2011 16:51:37 -0700 Subject: [PATCH] Did a sweep over all tests (except for filter tests) to convert them to pageSequence() where possible. This fixes the test bustages caused by the changePage() refactoring. Note that the "Multiple nested lists on a page" test is still busted, as it is on the HEAD. --- tests/unit/listview/listview_core.js | 289 +++++++++++++++++---------- 1 file changed, 185 insertions(+), 104 deletions(-) diff --git a/tests/unit/listview/listview_core.js b/tests/unit/listview/listview_core.js index 66132803..15d09e09 100644 --- a/tests/unit/listview/listview_core.js +++ b/tests/unit/listview/listview_core.js @@ -4,6 +4,7 @@ // TODO split out into seperate test files (function($){ + $.mobile.defaultTransition = "none"; module('Basic Linked list', { setup: function(){ @@ -19,62 +20,93 @@ }); asyncTest( "Slides to the listview page when the li a is clicked", function() { - $.testHelper.openPage("#basic-linked-test"); + $.testHelper.pageSequence([ + function(){ + $.testHelper.openPage("#basic-linked-test"); + }, - setTimeout(function(){ - $('#basic-linked-test li a').first().click(); - }, 500); + function(){ + $('#basic-linked-test li a').first().click(); + }, - setTimeout(function() { - ok($('#basic-link-results').hasClass('ui-page-active')); - start(); - }, 1000); + function(){ + ok($('#basic-link-results').hasClass('ui-page-active')); + start(); + } + ]); }); asyncTest( "Slides back to main page when back button is clicked", function() { - $.testHelper.openPage("#basic-link-results"); + $.testHelper.pageSequence([ + function(){ + $.testHelper.openPage("#basic-link-results"); + }, - window.history.back(); + function(){ + window.history.back(); + }, - setTimeout(function() { - ok($('#basic-linked-test').hasClass('ui-page-active')); - start(); - }, 1000); + function(){ + ok($('#basic-linked-test').hasClass('ui-page-active')); + start(); + } + ]); }); module('Nested List Test'); asyncTest( "Changes page to nested list test and enhances", function() { - $.testHelper.openPage("#nested-list-test"); - setTimeout(function() { - ok($('#nested-list-test').hasClass('ui-page-active'), "makes nested list test page active"); - ok($(':jqmData(url="nested-list-test&ui-page=More-animals-0")').length == 1, "Adds first UL to the page"); - ok($(':jqmData(url="nested-list-test&ui-page=Groups-of-animals-1")').length == 1, "Adds second nested UL to the page"); - start(); - }, 1000); + $.testHelper.pageSequence([ + function(){ + $.testHelper.openPage("#nested-list-test"); + }, + + function(){ + ok($('#nested-list-test').hasClass('ui-page-active'), "makes nested list test page active"); + ok($(':jqmData(url="nested-list-test&ui-page=More-animals-0")').length == 1, "Adds first UL to the page"); + ok($(':jqmData(url="nested-list-test&ui-page=Groups-of-animals-1")').length == 1, "Adds second nested UL to the page"); + start(); + } + ]); }); asyncTest( "change to nested page when the li a is clicked", function() { - $.testHelper.openPage("#nested-list-test"); - $('.ui-page-active li:eq(1) a:eq(0)').click(); - setTimeout(function() { - var $new_page = $(':jqmData(url="nested-list-test&ui-page=More-animals-0")'); - ok($new_page.hasClass('ui-page-active'), 'Makes the nested page the active page.'); - ok($('.ui-listview', $new_page).find(":contains('Rhumba of rattlesnakes')").length == 1, "The current page should have the proper text in the list."); - ok($('.ui-listview', $new_page).find(":contains('Shoal of Bass')").length == 1, "The current page should have the proper text in the list."); - start(); - }, 1000); + $.testHelper.pageSequence([ + function(){ + $.testHelper.openPage("#nested-list-test"); + }, + + function(){ + $('.ui-page-active li:eq(1) a:eq(0)').click(); + }, + + function(){ + var $new_page = $(':jqmData(url="nested-list-test&ui-page=More-animals-0")'); + + ok($new_page.hasClass('ui-page-active'), 'Makes the nested page the active page.'); + ok($('.ui-listview', $new_page).find(":contains('Rhumba of rattlesnakes')").length == 1, "The current page should have the proper text in the list."); + ok($('.ui-listview', $new_page).find(":contains('Shoal of Bass')").length == 1, "The current page should have the proper text in the list."); + start(); + } + ]); }); asyncTest( "should go back to top level when the back button is clicked", function() { - $.testHelper.openPage("#nested-list-test&ui-page=More-animals-0"); - window.history.back(); + $.testHelper.pageSequence([ + function(){ + $.testHelper.openPage("#nested-list-test&ui-page=More-animals-0"); + }, - setTimeout(function() { - ok($('#nested-list-test').hasClass('ui-page-active'), 'Transitions back to the parent nested page'); - start(); - }, 1000); + function(){ + window.history.back(); + }, + + function(){ + ok($('#nested-list-test').hasClass('ui-page-active'), 'Transitions back to the parent nested page'); + start(); + } + ]); }); test( "nested list title should use first text node, regardless of line breaks", function(){ @@ -82,89 +114,129 @@ }); asyncTest( "Multiple nested lists on a page", function() { - // https://github.com/jquery/jquery-mobile/issues/1617 - $.testHelper.openPage("#nested-lists-test"); + $.testHelper.pageSequence([ + function(){ + // https://github.com/jquery/jquery-mobile/issues/1617 + $.testHelper.openPage("#nested-lists-test"); + }, - setTimeout(function() { - $('.ui-page-active li:eq(2) a:eq(0)').click(); - - equal($('.ui-page-active .ui-content .ui-listview li').text(), "Sub Item 10Sub Item 11Sub Item 12", 'Text should be "Sub Item 10Sub Item 11Sub Item 12"'); - start(); - }, 500); + function(){ + $('.ui-page-active li:eq(2) a:eq(0)').click(); + + equal($('.ui-page-active .ui-content .ui-listview li').text(), "Sub Item 10Sub Item 11Sub Item 12", 'Text should be "Sub Item 10Sub Item 11Sub Item 12"'); + start(); + } + ]); }); module('Ordered Lists'); asyncTest( "changes to the numbered list page and enhances it", function() { - location.href = location.href.split('#')[0] + "#numbered-list-test"; - setTimeout(function() { - var $new_page = $('#numbered-list-test'); - ok($new_page.hasClass('ui-page-active'), "Makes the new page active when the hash is changed."); - ok($('.ui-link-inherit', $new_page).first().text() == "Number 1", "The text of the first LI should be Number 1"); - start(); - }, 1000); + $.testHelper.pageSequence([ + function(){ + $.testHelper.openPage("#numbered-list-test"); + }, + + function(){ + var $new_page = $('#numbered-list-test'); + ok($new_page.hasClass('ui-page-active'), "Makes the new page active when the hash is changed."); + ok($('.ui-link-inherit', $new_page).first().text() == "Number 1", "The text of the first LI should be Number 1"); + start(); + } + ]); }); asyncTest( "changes to number 1 page when the li a is clicked", function() { - $('#numbered-list-test li a').first().click(); - setTimeout(function() { - ok($('#numbered-list-results').hasClass('ui-page-active'), "The new numbered page was transitioned correctly."); - start(); - }, 1000); + $.testHelper.pageSequence([ + function(){ + $('#numbered-list-test li a').first().click(); + }, + + function(){ + ok($('#numbered-list-results').hasClass('ui-page-active'), "The new numbered page was transitioned correctly."); + start(); + } + ]); }); asyncTest( "takes us back to the numbered list when the back button is clicked", function() { - $.testHelper.openPage('#numbered-list-test') - $.testHelper.openPage('#numbered-list-results') - window.history.back(); - setTimeout(function() { - ok($('#numbered-list-test').hasClass('ui-page-active')); - start(); - }, 1000); + $.testHelper.pageSequence([ + function(){ + $.testHelper.openPage('#numbered-list-test') + }, + + function(){ + $.testHelper.openPage('#numbered-list-results') + }, + + function(){ + window.history.back(); + }, + + function(){ + ok($('#numbered-list-test').hasClass('ui-page-active')); + start(); + } + ]); }); module('Read only list'); asyncTest( "changes to the read only page when hash is changed", function() { - location.href = location.href.split('#')[0] + "#read-only-list-test"; - setTimeout(function() { - var $new_page = $('#read-only-list-test'); - ok($new_page.hasClass('ui-page-active'), "makes the read only page the active page"); - ok($('li', $new_page).first().text() === "Read", "The first LI has the proper text."); - start(); - }, 1000); + $.testHelper.pageSequence([ + function(){ + $.testHelper.openPage("#read-only-list-test") + }, + + function(){ + var $new_page = $('#read-only-list-test'); + ok($new_page.hasClass('ui-page-active'), "makes the read only page the active page"); + ok($('li', $new_page).first().text() === "Read", "The first LI has the proper text."); + start(); + } + ]); }); module('Split view list'); asyncTest( "changes the page to the split view list and enhances it correctly.", function() { - $.testHelper.openPage("#split-list-test"); + $.testHelper.pageSequence([ + function(){ + $.testHelper.openPage("#split-list-test"); + }, - setTimeout(function() { - var $new_page = $('#split-list-test'); - ok($('.ui-li-link-alt', $new_page).length == 3); - ok($('.ui-link-inherit', $new_page).length == 3); - start(); - }, 1000); + function(){ + var $new_page = $('#split-list-test'); + ok($('.ui-li-link-alt', $new_page).length == 3); + ok($('.ui-link-inherit', $new_page).length == 3); + start(); + } + ]); }); asyncTest( "change the page to the split view page 1 when the first link is clicked", function() { - $.testHelper.openPage("#split-list-test"); + $.testHelper.pageSequence([ + function(){ + $.testHelper.openPage("#split-list-test"); + }, - setTimeout(function(){ - $('.ui-page-active .ui-li a:eq(0)').click(); - }, 500); + function(){ + $('.ui-page-active .ui-li a:eq(0)').click(); + }, - setTimeout(function() { - ok($('#split-list-link1').hasClass('ui-page-active')); - start(); - }, 1000); + function(){ + ok($('#split-list-link1').hasClass('ui-page-active')); + start(); + } + ]); }); asyncTest( "Slide back to the parent list view when the back button is clicked", function() { - $.testHelper.openPage("#split-list-test"); + $.testHelper.pageSequence([ + function(){ + $.testHelper.openPage("#split-list-test"); + }, - $.testHelper.sequence([ function(){ $('.ui-page-active .ui-listview a:eq(0)').click(); }, @@ -173,36 +245,45 @@ history.back(); }, - function() { + function(){ ok($('#split-list-test').hasClass('ui-page-active')); start(); } - ], 1000); + ]); }); asyncTest( "Clicking on the icon (the second link) should take the user to other a href of this LI", function() { - $.testHelper.openPage("#split-list-test"); + $.testHelper.pageSequence([ + function(){ + $.testHelper.openPage("#split-list-test"); + }, - setTimeout(function(){ - $('.ui-page-active .ui-li-link-alt:eq(0)').click(); - }, 500); + function(){ + $('.ui-page-active .ui-li-link-alt:eq(0)').click(); + }, - setTimeout(function() { - ok($('#split-list-link2').hasClass('ui-page-active')); - start(); - }, 1000); + function(){ + ok($('#split-list-link2').hasClass('ui-page-active')); + start(); + } + ]); }); module( "List Dividers" ); asyncTest( "Makes the list divider page the active page and enhances it correctly.", function() { - location.href = location.href.split('#')[0] + "#list-divider-test"; - setTimeout(function() { - var $new_page = $('#list-divider-test'); - ok($new_page.find('.ui-li-divider').length == 2); - ok($new_page.hasClass('ui-page-active')); - start(); - }, 1000); + $.testHelper.pageSequence([ + function(){ + $.testHelper.openPage("#list-divider-test"); + }, + + function(){ + var $new_page = $('#list-divider-test'); + ok($new_page.find('.ui-li-divider').length == 2); + ok($new_page.hasClass('ui-page-active')); + start(); + } + ]); }); module( "Search Filter");