aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmanpreet Singh <apsdehal@gmail.com>2016-04-03 20:07:27 +0530
committerAmanpreet Singh <apsdehal@gmail.com>2016-04-14 00:06:11 +0530
commitd83db4f5284df9fd80c3a98b1a3c5b6ca31b0c9a (patch)
tree82fefced8aa05619188d4d6c99ab88520cefad23
parent435ed7e8d2e0221635494eedfbe22616f2a4814f (diff)
downloadjquery-ui-d83db4f5284df9fd80c3a98b1a3c5b6ca31b0c9a.tar.gz
jquery-ui-d83db4f5284df9fd80c3a98b1a3c5b6ca31b0c9a.zip
Accordion: Shift to use no globals
-rw-r--r--tests/unit/accordion/core.js144
-rw-r--r--tests/unit/accordion/events.js157
-rw-r--r--tests/unit/accordion/helper.js13
-rw-r--r--tests/unit/accordion/methods.js65
-rw-r--r--tests/unit/accordion/options.js331
5 files changed, 361 insertions, 349 deletions
diff --git a/tests/unit/accordion/core.js b/tests/unit/accordion/core.js
index 75f4b4ee3..119280bc9 100644
--- a/tests/unit/accordion/core.js
+++ b/tests/unit/accordion/core.js
@@ -1,129 +1,131 @@
define( [
+ "qunit",
"jquery",
"./helper",
"ui/widgets/accordion"
-], function( $, testHelper ) {
+], function( QUnit, $, testHelper ) {
var setupTeardown = testHelper.setupTeardown,
state = testHelper.state;
-module( "accordion: core", setupTeardown() );
+QUnit.module( "accordion: core", setupTeardown() );
$.each( { div: "#list1", ul: "#navigation", dl: "#accordion-dl" }, function( type, selector ) {
- test( "markup structure: " + type, function( assert ) {
- expect( 10 );
+ QUnit.test( "markup structure: " + type, function( assert ) {
+ assert.expect( 10 );
var element = $( selector ).accordion(),
headers = element.find( ".ui-accordion-header" ),
content = headers.next();
assert.hasClasses( element, "ui-accordion ui-widget" );
- equal( headers.length, 3, ".ui-accordion-header elements exist, correct number" );
+ assert.equal( headers.length, 3, ".ui-accordion-header elements exist, correct number" );
assert.hasClasses( headers[ 0 ],
"ui-accordion-header ui-accordion-header-active ui-accordion-icons" );
assert.hasClasses( headers[ 1 ],
"ui-accordion-header ui-accordion-header-collapsed ui-accordion-icons" );
assert.hasClasses( headers[ 2 ],
"ui-accordion-header ui-accordion-header-collapsed ui-accordion-icons" );
- equal( content.length, 3, ".ui-accordion-content elements exist, correct number" );
+ assert.equal( content.length, 3, ".ui-accordion-content elements exist, correct number" );
assert.hasClasses( content[ 0 ],
"ui-accordion-content ui-widget-content ui-accordion-content-active" );
assert.hasClasses( content[ 1 ], "ui-accordion-content ui-widget-content" );
assert.hasClasses( content[ 2 ], "ui-accordion-content ui-widget-content" );
- deepEqual( element.find( ".ui-accordion-header" ).next().get(),
+ assert.deepEqual( element.find( ".ui-accordion-header" ).next().get(),
element.find( ".ui-accordion-content" ).get(),
"content panels come immediately after headers" );
} );
} );
-test( "handle click on header-descendant", function() {
- expect( 1 );
+QUnit.test( "handle click on header-descendant", function( assert ) {
+ assert.expect( 1 );
var element = $( "#navigation" ).accordion();
$( "#navigation h2:eq(1) a" ).trigger( "click" );
- state( element, 0, 1, 0 );
+ state( assert, element, 0, 1, 0 );
} );
-test( "accessibility", function() {
- expect( 61 );
+QUnit.test( "accessibility", function( assert ) {
+ assert.expect( 61 );
var element = $( "#list1" ).accordion( {
active: 1,
collapsible: true
} ),
headers = element.find( ".ui-accordion-header" );
- equal( element.attr( "role" ), "tablist", "element role" );
+ assert.equal( element.attr( "role" ), "tablist", "element role" );
headers.each( function( i ) {
var header = headers.eq( i ),
panel = header.next();
- equal( header.attr( "role" ), "tab", "header " + i + " role" );
- equal( header.attr( "aria-controls" ), panel.attr( "id" ), "header " + i + " aria-controls" );
- equal( panel.attr( "role" ), "tabpanel", "panel " + i + " role" );
- equal( panel.attr( "aria-labelledby" ), header.attr( "id" ), "panel " + i + " aria-labelledby" );
+ assert.equal( header.attr( "role" ), "tab", "header " + i + " role" );
+ assert.equal( header.attr( "aria-controls" ), panel.attr( "id" ), "header " + i + " aria-controls" );
+ assert.equal( panel.attr( "role" ), "tabpanel", "panel " + i + " role" );
+ assert.equal( panel.attr( "aria-labelledby" ), header.attr( "id" ), "panel " + i + " aria-labelledby" );
} );
- equal( headers.eq( 1 ).attr( "tabindex" ), 0, "active header has tabindex=0" );
- equal( headers.eq( 1 ).attr( "aria-selected" ), "true", "active tab (1) has aria-selected=true" );
- equal( headers.eq( 1 ).attr( "aria-expanded" ), "true", "active tab (1) has aria-expanded=true" );
- equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "false", "active tabpanel (1) has aria-hidden=false" );
- equal( headers.eq( 0 ).attr( "tabindex" ), -1, "inactive header (0) has tabindex=-1" );
- equal( headers.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab (0) has aria-selected=false" );
- equal( headers.eq( 0 ).attr( "aria-expanded" ), "false", "inactive tab (0) has aria-expanded=false" );
- equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (0) has aria-hidden=true" );
- equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header (2) has tabindex=-1" );
- equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab (2) has aria-selected=false" );
- equal( headers.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab (2) has aria-expanded=false" );
- equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (2) has aria-hidden=true" );
+ assert.equal( headers.eq( 1 ).attr( "tabindex" ), 0, "active header has tabindex=0" );
+ assert.equal( headers.eq( 1 ).attr( "aria-selected" ), "true", "active tab (1) has aria-selected=true" );
+ assert.equal( headers.eq( 1 ).attr( "aria-expanded" ), "true", "active tab (1) has aria-expanded=true" );
+ assert.equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "false", "active tabpanel (1) has aria-hidden=false" );
+ assert.equal( headers.eq( 0 ).attr( "tabindex" ), -1, "inactive header (0) has tabindex=-1" );
+ assert.equal( headers.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab (0) has aria-selected=false" );
+ assert.equal( headers.eq( 0 ).attr( "aria-expanded" ), "false", "inactive tab (0) has aria-expanded=false" );
+ assert.equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (0) has aria-hidden=true" );
+ assert.equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header (2) has tabindex=-1" );
+ assert.equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab (2) has aria-selected=false" );
+ assert.equal( headers.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab (2) has aria-expanded=false" );
+ assert.equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (2) has aria-hidden=true" );
element.accordion( "option", "active", 0 );
- equal( headers.eq( 0 ).attr( "tabindex" ), 0, "active header (0) has tabindex=0" );
- equal( headers.eq( 0 ).attr( "aria-selected" ), "true", "active tab (0) has aria-selected=true" );
- equal( headers.eq( 0 ).attr( "aria-expanded" ), "true", "active tab (0) has aria-expanded=true" );
- equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "false", "active tabpanel (0) has aria-hidden=false" );
- equal( headers.eq( 1 ).attr( "tabindex" ), -1, "inactive header (1) has tabindex=-1" );
- equal( headers.eq( 1 ).attr( "aria-selected" ), "false", "inactive tab (1) has aria-selected=false" );
- equal( headers.eq( 1 ).attr( "aria-expanded" ), "false", "inactive tab (1) has aria-expanded=false" );
- equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (1) has aria-hidden=true" );
- equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header (2) has tabindex=-1" );
- equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab (2) has aria-selected=false" );
- equal( headers.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab (2) has aria-expanded=false" );
- equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (2) has aria-hidden=true" );
+ assert.equal( headers.eq( 0 ).attr( "tabindex" ), 0, "active header (0) has tabindex=0" );
+ assert.equal( headers.eq( 0 ).attr( "aria-selected" ), "true", "active tab (0) has aria-selected=true" );
+ assert.equal( headers.eq( 0 ).attr( "aria-expanded" ), "true", "active tab (0) has aria-expanded=true" );
+ assert.equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "false", "active tabpanel (0) has aria-hidden=false" );
+ assert.equal( headers.eq( 1 ).attr( "tabindex" ), -1, "inactive header (1) has tabindex=-1" );
+ assert.equal( headers.eq( 1 ).attr( "aria-selected" ), "false", "inactive tab (1) has aria-selected=false" );
+ assert.equal( headers.eq( 1 ).attr( "aria-expanded" ), "false", "inactive tab (1) has aria-expanded=false" );
+ assert.equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (1) has aria-hidden=true" );
+ assert.equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header (2) has tabindex=-1" );
+ assert.equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab (2) has aria-selected=false" );
+ assert.equal( headers.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab (2) has aria-expanded=false" );
+ assert.equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (2) has aria-hidden=true" );
element.accordion( "option", "active", false );
- equal( headers.eq( 0 ).attr( "tabindex" ), 0, "previously active header (0) has tabindex=0" );
- equal( headers.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab (0) has aria-selected=false" );
- equal( headers.eq( 0 ).attr( "aria-expanded" ), "false", "inactive tab (0) has aria-expanded=false" );
- equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (0) has aria-hidden=true" );
- equal( headers.eq( 1 ).attr( "tabindex" ), -1, "inactive header (1) has tabindex=-1" );
- equal( headers.eq( 1 ).attr( "aria-selected" ), "false", "inactive tab (1) has aria-selected=false" );
- equal( headers.eq( 1 ).attr( "aria-expanded" ), "false", "inactive tab (1) has aria-expanded=false" );
- equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (1) has aria-hidden=true" );
- equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header (2) has tabindex=-1" );
- equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab (2) has aria-selected=false" );
- equal( headers.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab (2) has aria-expanded=false" );
- equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (2) has aria-hidden=true" );
+ assert.equal( headers.eq( 0 ).attr( "tabindex" ), 0, "previously active header (0) has tabindex=0" );
+ assert.equal( headers.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab (0) has aria-selected=false" );
+ assert.equal( headers.eq( 0 ).attr( "aria-expanded" ), "false", "inactive tab (0) has aria-expanded=false" );
+ assert.equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (0) has aria-hidden=true" );
+ assert.equal( headers.eq( 1 ).attr( "tabindex" ), -1, "inactive header (1) has tabindex=-1" );
+ assert.equal( headers.eq( 1 ).attr( "aria-selected" ), "false", "inactive tab (1) has aria-selected=false" );
+ assert.equal( headers.eq( 1 ).attr( "aria-expanded" ), "false", "inactive tab (1) has aria-expanded=false" );
+ assert.equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (1) has aria-hidden=true" );
+ assert.equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header (2) has tabindex=-1" );
+ assert.equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab (2) has aria-selected=false" );
+ assert.equal( headers.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab (2) has aria-expanded=false" );
+ assert.equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (2) has aria-hidden=true" );
element.accordion( "option", "active", 1 );
- equal( headers.eq( 1 ).attr( "tabindex" ), 0, "active header has tabindex=0" );
- equal( headers.eq( 1 ).attr( "aria-selected" ), "true", "active tab (1) has aria-selected=true" );
- equal( headers.eq( 1 ).attr( "aria-expanded" ), "true", "active tab (1) has aria-expanded=true" );
- equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "false", "active tabpanel (1) has aria-hidden=false" );
- equal( headers.eq( 0 ).attr( "tabindex" ), -1, "inactive header (0) has tabindex=-1" );
- equal( headers.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab (0) has aria-selected=false" );
- equal( headers.eq( 0 ).attr( "aria-expanded" ), "false", "inactive tab (0) has aria-expanded=false" );
- equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (0) has aria-hidden=true" );
- equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header (2) has tabindex=-1" );
- equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab (2) has aria-selected=false" );
- equal( headers.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab (2) has aria-expanded=false" );
- equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (2) has aria-hidden=true" );
+ assert.equal( headers.eq( 1 ).attr( "tabindex" ), 0, "active header has tabindex=0" );
+ assert.equal( headers.eq( 1 ).attr( "aria-selected" ), "true", "active tab (1) has aria-selected=true" );
+ assert.equal( headers.eq( 1 ).attr( "aria-expanded" ), "true", "active tab (1) has aria-expanded=true" );
+ assert.equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "false", "active tabpanel (1) has aria-hidden=false" );
+ assert.equal( headers.eq( 0 ).attr( "tabindex" ), -1, "inactive header (0) has tabindex=-1" );
+ assert.equal( headers.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab (0) has aria-selected=false" );
+ assert.equal( headers.eq( 0 ).attr( "aria-expanded" ), "false", "inactive tab (0) has aria-expanded=false" );
+ assert.equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (0) has aria-hidden=true" );
+ assert.equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header (2) has tabindex=-1" );
+ assert.equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab (2) has aria-selected=false" );
+ assert.equal( headers.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab (2) has aria-expanded=false" );
+ assert.equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (2) has aria-hidden=true" );
} );
-asyncTest( "keyboard support", function( assert ) {
- expect( 13 );
+QUnit.test( "keyboard support", function( assert ) {
+ var ready = assert.async();
+ assert.expect( 13 );
var element = $( "#list1" ).accordion(),
headers = element.find( ".ui-accordion-header" ),
anchor = headers.eq( 1 ).next().find( "a" ).eq( 0 ),
keyCode = $.ui.keyCode;
- equal( headers.filter( ".ui-state-focus" ).length, 0, "no headers focused on init" );
+ assert.equal( headers.filter( ".ui-state-focus" ).length, 0, "no headers focused on init" );
headers.eq( 0 ).simulate( "focus" );
setTimeout( step1 );
@@ -180,13 +182,13 @@ asyncTest( "keyboard support", function( assert ) {
}
function step9() {
- equal( element.accordion( "option", "active" ), 2, "ENTER activates panel" );
+ assert.equal( element.accordion( "option", "active" ), 2, "ENTER activates panel" );
headers.eq( 1 ).simulate( "keydown", { keyCode: keyCode.SPACE } );
setTimeout( step10 );
}
function step10() {
- equal( element.accordion( "option", "active" ), 1, "SPACE activates panel" );
+ assert.equal( element.accordion( "option", "active" ), 1, "SPACE activates panel" );
anchor.simulate( "focus" );
setTimeout( step11 );
}
@@ -200,7 +202,7 @@ asyncTest( "keyboard support", function( assert ) {
function step12() {
assert.hasClasses( headers.eq( 1 ), "ui-state-focus", "CTRL+UP moves focus to header" );
- start();
+ ready();
}
} );
diff --git a/tests/unit/accordion/events.js b/tests/unit/accordion/events.js
index 1634b402d..b9af7ce06 100644
--- a/tests/unit/accordion/events.js
+++ b/tests/unit/accordion/events.js
@@ -1,16 +1,17 @@
define( [
+ "qunit",
"jquery",
"./helper",
"ui/widgets/accordion"
-], function( $, testHelper ) {
+], function( QUnit, $, testHelper ) {
var setupTeardown = testHelper.setupTeardown,
state = testHelper.state;
-module( "accordion: events", setupTeardown() );
+QUnit.module( "accordion: events", setupTeardown() );
-test( "create", function() {
- expect( 10 );
+QUnit.test( "create", function( assert ) {
+ assert.expect( 10 );
var element = $( "#list1" ),
headers = element.children( "h3" ),
@@ -18,10 +19,10 @@ test( "create", function() {
element.accordion( {
create: function( event, ui ) {
- equal( ui.header.length, 1, "header length" );
- strictEqual( ui.header[ 0 ], headers[ 0 ], "header" );
- equal( ui.panel.length, 1, "panel length" );
- strictEqual( ui.panel[ 0 ], contents[ 0 ], "panel" );
+ assert.equal( ui.header.length, 1, "header length" );
+ assert.strictEqual( ui.header[ 0 ], headers[ 0 ], "header" );
+ assert.equal( ui.panel.length, 1, "panel length" );
+ assert.strictEqual( ui.panel[ 0 ], contents[ 0 ], "panel" );
}
} );
element.accordion( "destroy" );
@@ -29,10 +30,10 @@ test( "create", function() {
element.accordion( {
active: 2,
create: function( event, ui ) {
- equal( ui.header.length, 1, "header length" );
- strictEqual( ui.header[ 0 ], headers[ 2 ], "header" );
- equal( ui.panel.length, 1, "panel length" );
- strictEqual( ui.panel[ 0 ], contents[ 2 ], "panel" );
+ assert.equal( ui.header.length, 1, "header length" );
+ assert.strictEqual( ui.header[ 0 ], headers[ 2 ], "header" );
+ assert.equal( ui.panel.length, 1, "panel length" );
+ assert.strictEqual( ui.panel[ 0 ], contents[ 2 ], "panel" );
}
} );
element.accordion( "destroy" );
@@ -41,15 +42,15 @@ test( "create", function() {
active: false,
collapsible: true,
create: function( event, ui ) {
- equal( ui.header.length, 0, "header length" );
- equal( ui.panel.length, 0, "panel length" );
+ assert.equal( ui.header.length, 0, "header length" );
+ assert.equal( ui.panel.length, 0, "panel length" );
}
} );
element.accordion( "destroy" );
} );
-test( "beforeActivate", function() {
- expect( 38 );
+QUnit.test( "beforeActivate", function( assert ) {
+ assert.expect( 38 );
var element = $( "#list1" ).accordion( {
active: false,
collapsible: true
@@ -58,63 +59,63 @@ test( "beforeActivate", function() {
content = element.find( ".ui-accordion-content" );
element.one( "accordionbeforeactivate", function( event, ui ) {
- ok( !( "originalEvent" in event ) );
- equal( ui.oldHeader.length, 0 );
- equal( ui.oldPanel.length, 0 );
- equal( ui.newHeader.length, 1 );
- strictEqual( ui.newHeader[ 0 ], headers[ 0 ] );
- equal( ui.newPanel.length, 1 );
- strictEqual( ui.newPanel[ 0 ], content[ 0 ] );
- state( element, 0, 0, 0 );
+ assert.ok( !( "originalEvent" in event ) );
+ assert.equal( ui.oldHeader.length, 0 );
+ assert.equal( ui.oldPanel.length, 0 );
+ assert.equal( ui.newHeader.length, 1 );
+ assert.strictEqual( ui.newHeader[ 0 ], headers[ 0 ] );
+ assert.equal( ui.newPanel.length, 1 );
+ assert.strictEqual( ui.newPanel[ 0 ], content[ 0 ] );
+ state( assert, element, 0, 0, 0 );
} );
element.accordion( "option", "active", 0 );
- state( element, 1, 0, 0 );
+ state( assert, element, 1, 0, 0 );
element.one( "accordionbeforeactivate", function( event, ui ) {
- equal( event.originalEvent.type, "click" );
- equal( ui.oldHeader.length, 1 );
- strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] );
- equal( ui.oldPanel.length, 1 );
- strictEqual( ui.oldPanel[ 0 ], content[ 0 ] );
- equal( ui.newHeader.length, 1 );
- strictEqual( ui.newHeader[ 0 ], headers[ 1 ] );
- equal( ui.newPanel.length, 1 );
- strictEqual( ui.newPanel[ 0 ], content[ 1 ] );
- state( element, 1, 0, 0 );
+ assert.equal( event.originalEvent.type, "click" );
+ assert.equal( ui.oldHeader.length, 1 );
+ assert.strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] );
+ assert.equal( ui.oldPanel.length, 1 );
+ assert.strictEqual( ui.oldPanel[ 0 ], content[ 0 ] );
+ assert.equal( ui.newHeader.length, 1 );
+ assert.strictEqual( ui.newHeader[ 0 ], headers[ 1 ] );
+ assert.equal( ui.newPanel.length, 1 );
+ assert.strictEqual( ui.newPanel[ 0 ], content[ 1 ] );
+ state( assert, element, 1, 0, 0 );
} );
headers.eq( 1 ).trigger( "click" );
- state( element, 0, 1, 0 );
+ state( assert, element, 0, 1, 0 );
element.one( "accordionbeforeactivate", function( event, ui ) {
- ok( !( "originalEvent" in event ) );
- equal( ui.oldHeader.length, 1 );
- strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] );
- equal( ui.oldPanel.length, 1 );
- strictEqual( ui.oldPanel[ 0 ], content[ 1 ] );
- equal( ui.newHeader.length, 0 );
- equal( ui.newPanel.length, 0 );
- state( element, 0, 1, 0 );
+ assert.ok( !( "originalEvent" in event ) );
+ assert.equal( ui.oldHeader.length, 1 );
+ assert.strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] );
+ assert.equal( ui.oldPanel.length, 1 );
+ assert.strictEqual( ui.oldPanel[ 0 ], content[ 1 ] );
+ assert.equal( ui.newHeader.length, 0 );
+ assert.equal( ui.newPanel.length, 0 );
+ state( assert, element, 0, 1, 0 );
} );
element.accordion( "option", "active", false );
- state( element, 0, 0, 0 );
+ state( assert, element, 0, 0, 0 );
element.one( "accordionbeforeactivate", function( event, ui ) {
- ok( !( "originalEvent" in event ) );
- equal( ui.oldHeader.length, 0 );
- equal( ui.oldPanel.length, 0 );
- equal( ui.newHeader.length, 1 );
- strictEqual( ui.newHeader[ 0 ], headers[ 2 ] );
- equal( ui.newPanel.length, 1 );
- strictEqual( ui.newPanel[ 0 ], content[ 2 ] );
+ assert.ok( !( "originalEvent" in event ) );
+ assert.equal( ui.oldHeader.length, 0 );
+ assert.equal( ui.oldPanel.length, 0 );
+ assert.equal( ui.newHeader.length, 1 );
+ assert.strictEqual( ui.newHeader[ 0 ], headers[ 2 ] );
+ assert.equal( ui.newPanel.length, 1 );
+ assert.strictEqual( ui.newPanel[ 0 ], content[ 2 ] );
event.preventDefault();
- state( element, 0, 0, 0 );
+ state( assert, element, 0, 0, 0 );
} );
element.accordion( "option", "active", 2 );
- state( element, 0, 0, 0 );
+ state( assert, element, 0, 0, 0 );
} );
-test( "activate", function() {
- expect( 21 );
+QUnit.test( "activate", function( assert ) {
+ assert.expect( 21 );
var element = $( "#list1" ).accordion( {
active: false,
collapsible: true
@@ -123,44 +124,44 @@ test( "activate", function() {
content = element.find( ".ui-accordion-content" );
element.one( "accordionactivate", function( event, ui ) {
- equal( ui.oldHeader.length, 0 );
- equal( ui.oldPanel.length, 0 );
- equal( ui.newHeader.length, 1 );
- strictEqual( ui.newHeader[ 0 ], headers[ 0 ] );
- equal( ui.newPanel.length, 1 );
- strictEqual( ui.newPanel[ 0 ], content[ 0 ] );
+ assert.equal( ui.oldHeader.length, 0 );
+ assert.equal( ui.oldPanel.length, 0 );
+ assert.equal( ui.newHeader.length, 1 );
+ assert.strictEqual( ui.newHeader[ 0 ], headers[ 0 ] );
+ assert.equal( ui.newPanel.length, 1 );
+ assert.strictEqual( ui.newPanel[ 0 ], content[ 0 ] );
} );
element.accordion( "option", "active", 0 );
element.one( "accordionactivate", function( event, ui ) {
- equal( ui.oldHeader.length, 1 );
- strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] );
- equal( ui.oldPanel.length, 1 );
- strictEqual( ui.oldPanel[ 0 ], content[ 0 ] );
- equal( ui.newHeader.length, 1 );
- strictEqual( ui.newHeader[ 0 ], headers[ 1 ] );
- equal( ui.newPanel.length, 1 );
- strictEqual( ui.newPanel[ 0 ], content[ 1 ] );
+ assert.equal( ui.oldHeader.length, 1 );
+ assert.strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] );
+ assert.equal( ui.oldPanel.length, 1 );
+ assert.strictEqual( ui.oldPanel[ 0 ], content[ 0 ] );
+ assert.equal( ui.newHeader.length, 1 );
+ assert.strictEqual( ui.newHeader[ 0 ], headers[ 1 ] );
+ assert.equal( ui.newPanel.length, 1 );
+ assert.strictEqual( ui.newPanel[ 0 ], content[ 1 ] );
} );
headers.eq( 1 ).trigger( "click" );
element.one( "accordionactivate", function( event, ui ) {
- equal( ui.oldHeader.length, 1 );
- strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] );
- equal( ui.oldPanel.length, 1 );
- strictEqual( ui.oldPanel[ 0 ], content[ 1 ] );
- equal( ui.newHeader.length, 0 );
- equal( ui.newPanel.length, 0 );
+ assert.equal( ui.oldHeader.length, 1 );
+ assert.strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] );
+ assert.equal( ui.oldPanel.length, 1 );
+ assert.strictEqual( ui.oldPanel[ 0 ], content[ 1 ] );
+ assert.equal( ui.newHeader.length, 0 );
+ assert.equal( ui.newPanel.length, 0 );
} );
element.accordion( "option", "active", false );
// Prevent activation
element.one( "accordionbeforeactivate", function( event ) {
- ok( true );
+ assert.ok( true );
event.preventDefault();
} );
element.one( "accordionactivate", function() {
- ok( false );
+ assert.ok( false );
} );
element.accordion( "option", "active", 1 );
} );
diff --git a/tests/unit/accordion/helper.js b/tests/unit/accordion/helper.js
index b47510733..80bfc1854 100644
--- a/tests/unit/accordion/helper.js
+++ b/tests/unit/accordion/helper.js
@@ -1,13 +1,14 @@
define( [
+ "qunit",
"jquery",
"lib/helper",
"ui/widgets/accordion"
-], function( $, helper ) {
+], function( QUnit, $, helper ) {
return $.extend( helper, {
- equalHeight: function( accordion, height ) {
+ equalHeight: function( assert, accordion, height ) {
accordion.find( ".ui-accordion-content" ).each( function() {
- equal( $( this ).outerHeight(), height );
+ assert.equal( $( this ).outerHeight(), height );
} );
},
@@ -23,12 +24,12 @@ return $.extend( helper, {
};
},
- state: function( accordion ) {
- var expected = $.makeArray( arguments ).slice( 1 ),
+ state: function( assert, accordion ) {
+ var expected = $.makeArray( arguments ).slice( 2 ),
actual = accordion.find( ".ui-accordion-content" ).map( function() {
return $( this ).css( "display" ) === "none" ? 0 : 1;
} ).get();
- QUnit.push( QUnit.equiv( actual, expected ), actual, expected );
+ assert.deepEqual( actual, expected );
}
} );
diff --git a/tests/unit/accordion/methods.js b/tests/unit/accordion/methods.js
index 3b1696e45..1b11e91ee 100644
--- a/tests/unit/accordion/methods.js
+++ b/tests/unit/accordion/methods.js
@@ -1,47 +1,48 @@
define( [
+ "qunit",
"jquery",
"./helper",
"ui/widgets/accordion"
-], function( $, testHelper ) {
+], function( QUnit, $, testHelper ) {
var equalHeight = testHelper.equalHeight,
setupTeardown = testHelper.setupTeardown,
state = testHelper.state;
-module( "accordion: methods", setupTeardown() );
+QUnit.module( "accordion: methods", setupTeardown() );
-test( "destroy", function( assert ) {
- expect( 1 );
+QUnit.test( "destroy", function( assert ) {
+ assert.expect( 1 );
assert.domEqual( "#list1", function() {
$( "#list1" ).accordion().accordion( "destroy" );
} );
} );
-test( "enable/disable", function( assert ) {
- expect( 7 );
+QUnit.test( "enable/disable", function( assert ) {
+ assert.expect( 7 );
var element = $( "#list1" ).accordion();
- state( element, 1, 0, 0 );
+ state( assert, element, 1, 0, 0 );
element.accordion( "disable" );
assert.hasClasses( element, "ui-state-disabled" );
- equal( element.attr( "aria-disabled" ), "true", "element gets aria-disabled" );
+ assert.equal( element.attr( "aria-disabled" ), "true", "element gets aria-disabled" );
assert.hasClasses( element, "ui-accordion-disabled" );
// Event does nothing
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "click" );
- state( element, 1, 0, 0 );
+ state( assert, element, 1, 0, 0 );
// Option still works
element.accordion( "option", "active", 1 );
- state( element, 0, 1, 0 );
+ state( assert, element, 0, 1, 0 );
element.accordion( "enable" );
element.accordion( "option", "active", 2 );
- state( element, 0, 0, 1 );
+ state( assert, element, 0, 0, 1 );
} );
-test( "refresh", function() {
- expect( 19 );
+QUnit.test( "refresh", function( assert ) {
+ assert.expect( 19 );
var element = $( "#navigation" )
.parent()
.height( 300 )
@@ -49,37 +50,37 @@ test( "refresh", function() {
.accordion( {
heightStyle: "fill"
} );
- equalHeight( element, 255 );
+ equalHeight( assert, element, 255 );
element.parent().height( 500 );
element.accordion( "refresh" );
- equalHeight( element, 455 );
+ equalHeight( assert, element, 455 );
element = $( "#list1" );
element.accordion();
- state( element, 1, 0, 0 );
+ state( assert, element, 1, 0, 0 );
// Disable panel via markup
element.find( "h3.bar" ).eq( 1 ).addClass( "ui-state-disabled" );
element.accordion( "refresh" );
- state( element, 1, 0, 0 );
+ state( assert, element, 1, 0, 0 );
// Don't add multiple icons
element.accordion( "refresh" );
- equal( element.find( ".ui-accordion-header-icon" ).length, 3 );
+ assert.equal( element.find( ".ui-accordion-header-icon" ).length, 3 );
// Add a panel
element
.append( "<h3 class='bar' id='new_1'>new 1</h3>" )
.append( "<div class='foo' id='new_1_panel'>new 1</div>" );
element.accordion( "refresh" );
- state( element, 1, 0, 0, 0 );
+ state( assert, element, 1, 0, 0, 0 );
// Remove all tabs
element.find( "h3.bar, div.foo" ).remove();
element.accordion( "refresh" );
- state( element );
- equal( element.accordion( "option", "active" ), false, "no active accordion panel" );
+ state( assert, element );
+ assert.equal( element.accordion( "option", "active" ), false, "no active accordion panel" );
// Add panels
element
@@ -92,46 +93,46 @@ test( "refresh", function() {
.append( "<h3 class='bar' id='new_5'>new 5</h3>" )
.append( "<div class='foo' id='new_5_panel'>new 5</div>" );
element.accordion( "refresh" );
- state( element, 1, 0, 0, 0 );
+ state( assert, element, 1, 0, 0, 0 );
// Activate third tab
element.accordion( "option", "active", 2 );
- state( element, 0, 0, 1, 0 );
+ state( assert, element, 0, 0, 1, 0 );
// Remove fourth panel, third panel should stay active
element.find( "h3.bar" ).eq( 3 ).remove();
element.find( "div.foo" ).eq( 3 ).remove();
element.accordion( "refresh" );
- state( element, 0, 0, 1 );
+ state( assert, element, 0, 0, 1 );
// Remove third (active) panel, second panel should become active
element.find( "h3.bar" ).eq( 2 ).remove();
element.find( "div.foo" ).eq( 2 ).remove();
element.accordion( "refresh" );
- state( element, 0, 1 );
+ state( assert, element, 0, 1 );
// Remove first panel, previously active panel (now first) should stay active
element.find( "h3.bar" ).eq( 0 ).remove();
element.find( "div.foo" ).eq( 0 ).remove();
element.accordion( "refresh" );
- state( element, 1 );
+ state( assert, element, 1 );
// Collapse all panels
element.accordion( "option", {
collapsible: true,
active: false
} );
- state( element, 0 );
+ state( assert, element, 0 );
element.accordion( "refresh" );
- state( element, 0 );
+ state( assert, element, 0 );
} );
-test( "widget", function() {
- expect( 2 );
+QUnit.test( "widget", function( assert ) {
+ assert.expect( 2 );
var element = $( "#list1" ).accordion(),
widgetElement = element.accordion( "widget" );
- equal( widgetElement.length, 1, "one element" );
- strictEqual( widgetElement[ 0 ], element[ 0 ], "same element" );
+ assert.equal( widgetElement.length, 1, "one element" );
+ assert.strictEqual( widgetElement[ 0 ], element[ 0 ], "same element" );
} );
} );
diff --git a/tests/unit/accordion/options.js b/tests/unit/accordion/options.js
index 228a8be40..2dec303a9 100644
--- a/tests/unit/accordion/options.js
+++ b/tests/unit/accordion/options.js
@@ -1,56 +1,57 @@
define( [
+ "qunit",
"jquery",
"./helper",
"ui/widgets/accordion"
-], function( $, testHelper ) {
+], function( QUnit, $, testHelper ) {
var equalHeight = testHelper.equalHeight,
setupTeardown = testHelper.setupTeardown,
state = testHelper.state;
-module( "accordion: options", setupTeardown() );
+QUnit.module( "accordion: options", setupTeardown() );
-test( "{ active: default }", function() {
- expect( 2 );
+QUnit.test( "{ active: default }", function( assert ) {
+ assert.expect( 2 );
var element = $( "#list1" ).accordion();
- equal( element.accordion( "option", "active" ), 0 );
- state( element, 1, 0, 0 );
+ assert.equal( element.accordion( "option", "active" ), 0 );
+ state( assert, element, 1, 0, 0 );
} );
-test( "{ active: null }", function() {
- expect( 2 );
+QUnit.test( "{ active: null }", function( assert ) {
+ assert.expect( 2 );
var element = $( "#list1" ).accordion( {
active: null
} );
- equal( element.accordion( "option", "active" ), 0 );
- state( element, 1, 0, 0 );
+ assert.equal( element.accordion( "option", "active" ), 0 );
+ state( assert, element, 1, 0, 0 );
} );
-test( "{ active: false }", function() {
- expect( 7 );
+QUnit.test( "{ active: false }", function( assert ) {
+ assert.expect( 7 );
var element = $( "#list1" ).accordion( {
active: false,
collapsible: true
} );
- state( element, 0, 0, 0 );
- equal( element.find( ".ui-accordion-header.ui-state-active" ).length, 0, "no headers selected" );
- equal( element.accordion( "option", "active" ), false );
+ state( assert, element, 0, 0, 0 );
+ assert.equal( element.find( ".ui-accordion-header.ui-state-active" ).length, 0, "no headers selected" );
+ assert.equal( element.accordion( "option", "active" ), false );
element.accordion( "option", "collapsible", false );
- state( element, 1, 0, 0 );
- equal( element.accordion( "option", "active" ), 0 );
+ state( assert, element, 1, 0, 0 );
+ assert.equal( element.accordion( "option", "active" ), 0 );
element.accordion( "destroy" );
element.accordion( {
active: false
} );
- state( element, 1, 0, 0 );
- strictEqual( element.accordion( "option", "active" ), 0 );
+ state( assert, element, 1, 0, 0 );
+ assert.strictEqual( element.accordion( "option", "active" ), 0 );
} );
// http://bugs.jqueryui.com/ticket/11938
-test( "{ active: false, collapsible: true }", function() {
- expect( 1 );
+QUnit.test( "{ active: false, collapsible: true }", function( assert ) {
+ assert.expect( 1 );
var element = $( "#collapsible" ).accordion(),
height = element.outerHeight();
@@ -61,71 +62,72 @@ test( "{ active: false, collapsible: true }", function() {
collapsible: true
} )
.accordion( "option", "active", 0 );
- equal( element.outerHeight(), height );
+ assert.equal( element.outerHeight(), height );
} );
-test( "{ active: Number }", function() {
- expect( 8 );
+QUnit.test( "{ active: Number }", function( assert ) {
+ assert.expect( 8 );
var element = $( "#list1" ).accordion( {
active: 2
} );
- equal( element.accordion( "option", "active" ), 2 );
- state( element, 0, 0, 1 );
+ assert.equal( element.accordion( "option", "active" ), 2 );
+ state( assert, element, 0, 0, 1 );
element.accordion( "option", "active", 0 );
- equal( element.accordion( "option", "active" ), 0 );
- state( element, 1, 0, 0 );
+ assert.equal( element.accordion( "option", "active" ), 0 );
+ state( assert, element, 1, 0, 0 );
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "click" );
- equal( element.accordion( "option", "active" ), 1 );
- state( element, 0, 1, 0 );
+ assert.equal( element.accordion( "option", "active" ), 1 );
+ state( assert, element, 0, 1, 0 );
element.accordion( "option", "active", 10 );
- equal( element.accordion( "option", "active" ), 1 );
- state( element, 0, 1, 0 );
+ assert.equal( element.accordion( "option", "active" ), 1 );
+ state( assert, element, 0, 1, 0 );
} );
-test( "{ active: -Number }", function() {
- expect( 8 );
+QUnit.test( "{ active: -Number }", function( assert ) {
+ assert.expect( 8 );
var element = $( "#list1" ).accordion( {
active: -1
} );
- equal( element.accordion( "option", "active" ), 2 );
- state( element, 0, 0, 1 );
+ assert.equal( element.accordion( "option", "active" ), 2 );
+ state( assert, element, 0, 0, 1 );
element.accordion( "option", "active", -2 );
- equal( element.accordion( "option", "active" ), 1 );
- state( element, 0, 1, 0 );
+ assert.equal( element.accordion( "option", "active" ), 1 );
+ state( assert, element, 0, 1, 0 );
element.accordion( "option", "active", -10 );
- equal( element.accordion( "option", "active" ), 1 );
- state( element, 0, 1, 0 );
+ assert.equal( element.accordion( "option", "active" ), 1 );
+ state( assert, element, 0, 1, 0 );
element.accordion( "option", "active", -3 );
- equal( element.accordion( "option", "active" ), 0 );
- state( element, 1, 0, 0 );
+ assert.equal( element.accordion( "option", "active" ), 0 );
+ state( assert, element, 1, 0, 0 );
} );
-test( "{ animate: false }", function() {
- expect( 3 );
+QUnit.test( "{ animate: false }", function( assert ) {
+ assert.expect( 3 );
var element = $( "#list1" ).accordion( {
animate: false
} ),
panels = element.find( ".ui-accordion-content" ),
animate = $.fn.animate;
$.fn.animate = function() {
- ok( false, ".animate() called" );
+ assert.ok( false, ".animate() called" );
};
- ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
+ assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
element.accordion( "option", "active", 1 );
- ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
- ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
+ assert.ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
+ assert.ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
$.fn.animate = animate;
} );
-asyncTest( "{ animate: Number }", function() {
- expect( 7 );
+QUnit.test( "{ animate: Number }", function( assert ) {
+ var ready = assert.async();
+ assert.expect( 7 );
var element = $( "#list1" ).accordion( {
animate: 100
} ),
@@ -134,23 +136,24 @@ asyncTest( "{ animate: Number }", function() {
// Called twice (both panels)
$.fn.animate = function( props, options ) {
- equal( options.duration, 100, "correct duration" );
- equal( options.easing, undefined, "default easing" );
+ assert.equal( options.duration, 100, "correct duration" );
+ assert.equal( options.easing, undefined, "default easing" );
animate.apply( this, arguments );
};
- ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
+ assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
element.accordion( "option", "active", 1 );
panels.promise().done( function() {
- ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
- ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
+ assert.ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
+ assert.ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
$.fn.animate = animate;
- start();
+ ready();
} );
} );
-asyncTest( "{ animate: String }", function() {
- expect( 7 );
+QUnit.test( "{ animate: String }", function( assert ) {
+ var ready = assert.async();
+ assert.expect( 7 );
var element = $( "#list1" ).accordion( {
animate: "linear"
} ),
@@ -159,23 +162,24 @@ asyncTest( "{ animate: String }", function() {
// Called twice (both panels)
$.fn.animate = function( props, options ) {
- equal( options.duration, undefined, "default duration" );
- equal( options.easing, "linear", "correct easing" );
+ assert.equal( options.duration, undefined, "default duration" );
+ assert.equal( options.easing, "linear", "correct easing" );
animate.apply( this, arguments );
};
- ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
+ assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
element.accordion( "option", "active", 1 );
panels.promise().done( function() {
- ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
- ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
+ assert.ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
+ assert.ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
$.fn.animate = animate;
- start();
+ ready();
} );
} );
-asyncTest( "{ animate: {} }", function() {
- expect( 7 );
+QUnit.test( "{ animate: {} }", function( assert ) {
+ var ready = assert.async();
+ assert.expect( 7 );
var element = $( "#list1" ).accordion( {
animate: {}
} ),
@@ -184,23 +188,24 @@ asyncTest( "{ animate: {} }", function() {
// Called twice (both panels)
$.fn.animate = function( props, options ) {
- equal( options.duration, undefined, "default duration" );
- equal( options.easing, undefined, "default easing" );
+ assert.equal( options.duration, undefined, "default duration" );
+ assert.equal( options.easing, undefined, "default easing" );
animate.apply( this, arguments );
};
- ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
+ assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
element.accordion( "option", "active", 1 );
panels.promise().done( function() {
- ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
- ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
+ assert.ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
+ assert.ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
$.fn.animate = animate;
- start();
+ ready();
} );
} );
-asyncTest( "{ animate: { duration, easing } }", function() {
- expect( 7 );
+QUnit.test( "{ animate: { duration, easing } }", function( assert ) {
+ var ready = assert.async();
+ assert.expect( 7 );
var element = $( "#list1" ).accordion( {
animate: { duration: 100, easing: "linear" }
} ),
@@ -209,23 +214,24 @@ asyncTest( "{ animate: { duration, easing } }", function() {
// Called twice (both panels)
$.fn.animate = function( props, options ) {
- equal( options.duration, 100, "correct duration" );
- equal( options.easing, "linear", "correct easing" );
+ assert.equal( options.duration, 100, "correct duration" );
+ assert.equal( options.easing, "linear", "correct easing" );
animate.apply( this, arguments );
};
- ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
+ assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
element.accordion( "option", "active", 1 );
panels.promise().done( function() {
- ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
- ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
+ assert.ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
+ assert.ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
$.fn.animate = animate;
- start();
+ ready();
} );
} );
-asyncTest( "{ animate: { duration, easing } }, animate down", function() {
- expect( 7 );
+QUnit.test( "{ animate: { duration, easing } }, animate down", function( assert ) {
+ var ready = assert.async();
+ assert.expect( 7 );
var element = $( "#list1" ).accordion( {
active: 1,
animate: { duration: 100, easing: "linear" }
@@ -235,23 +241,24 @@ asyncTest( "{ animate: { duration, easing } }, animate down", function() {
// Called twice (both panels)
$.fn.animate = function( props, options ) {
- equal( options.duration, 100, "correct duration" );
- equal( options.easing, "linear", "correct easing" );
+ assert.equal( options.duration, 100, "correct duration" );
+ assert.equal( options.easing, "linear", "correct easing" );
animate.apply( this, arguments );
};
- ok( panels.eq( 1 ).is( ":visible" ), "first panel visible" );
+ assert.ok( panels.eq( 1 ).is( ":visible" ), "first panel visible" );
element.accordion( "option", "active", 0 );
panels.promise().done( function() {
- ok( panels.eq( 1 ).is( ":hidden" ), "first panel hidden" );
- ok( panels.eq( 0 ).is( ":visible" ), "second panel visible" );
+ assert.ok( panels.eq( 1 ).is( ":hidden" ), "first panel hidden" );
+ assert.ok( panels.eq( 0 ).is( ":visible" ), "second panel visible" );
$.fn.animate = animate;
- start();
+ ready();
} );
} );
-asyncTest( "{ animate: { duration, easing, down } }, animate down", function() {
- expect( 7 );
+QUnit.test( "{ animate: { duration, easing, down } }, animate down", function( assert ) {
+ var ready = assert.async();
+ assert.expect( 7 );
var element = $( "#list1" ).accordion( {
active: 1,
animate: {
@@ -267,156 +274,156 @@ asyncTest( "{ animate: { duration, easing, down } }, animate down", function() {
// Called twice (both panels)
$.fn.animate = function( props, options ) {
- equal( options.duration, 100, "correct duration" );
- equal( options.easing, "swing", "correct easing" );
+ assert.equal( options.duration, 100, "correct duration" );
+ assert.equal( options.easing, "swing", "correct easing" );
animate.apply( this, arguments );
};
- ok( panels.eq( 1 ).is( ":visible" ), "first panel visible" );
+ assert.ok( panels.eq( 1 ).is( ":visible" ), "first panel visible" );
element.accordion( "option", "active", 0 );
panels.promise().done( function() {
- ok( panels.eq( 1 ).is( ":hidden" ), "first panel hidden" );
- ok( panels.eq( 0 ).is( ":visible" ), "second panel visible" );
+ assert.ok( panels.eq( 1 ).is( ":hidden" ), "first panel hidden" );
+ assert.ok( panels.eq( 0 ).is( ":visible" ), "second panel visible" );
$.fn.animate = animate;
- start();
+ ready();
} );
} );
-test( "{ collapsible: false }", function() {
- expect( 4 );
+QUnit.test( "{ collapsible: false }", function( assert ) {
+ assert.expect( 4 );
var element = $( "#list1" ).accordion( {
active: 1
} );
element.accordion( "option", "active", false );
- equal( element.accordion( "option", "active" ), 1 );
- state( element, 0, 1, 0 );
+ assert.equal( element.accordion( "option", "active" ), 1 );
+ state( assert, element, 0, 1, 0 );
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "click" );
- equal( element.accordion( "option", "active" ), 1 );
- state( element, 0, 1, 0 );
+ assert.equal( element.accordion( "option", "active" ), 1 );
+ state( assert, element, 0, 1, 0 );
} );
-test( "{ collapsible: true }", function() {
- expect( 6 );
+QUnit.test( "{ collapsible: true }", function( assert ) {
+ assert.expect( 6 );
var element = $( "#list1" ).accordion( {
active: 1,
collapsible: true
} );
element.accordion( "option", "active", false );
- equal( element.accordion( "option", "active" ), false );
- state( element, 0, 0, 0 );
+ assert.equal( element.accordion( "option", "active" ), false );
+ state( assert, element, 0, 0, 0 );
element.accordion( "option", "active", 1 );
- equal( element.accordion( "option", "active" ), 1 );
- state( element, 0, 1, 0 );
+ assert.equal( element.accordion( "option", "active" ), 1 );
+ state( assert, element, 0, 1, 0 );
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "click" );
- equal( element.accordion( "option", "active" ), false );
- state( element, 0, 0, 0 );
+ assert.equal( element.accordion( "option", "active" ), false );
+ state( assert, element, 0, 0, 0 );
} );
-test( "{ event: null }", function() {
- expect( 5 );
+QUnit.test( "{ event: null }", function( assert ) {
+ assert.expect( 5 );
var element = $( "#list1" ).accordion( {
event: null
} );
- state( element, 1, 0, 0 );
+ state( assert, element, 1, 0, 0 );
element.accordion( "option", "active", 1 );
- equal( element.accordion( "option", "active" ), 1 );
- state( element, 0, 1, 0 );
+ assert.equal( element.accordion( "option", "active" ), 1 );
+ state( assert, element, 0, 1, 0 );
// Ensure default click handler isn't bound
element.find( ".ui-accordion-header" ).eq( 2 ).trigger( "click" );
- equal( element.accordion( "option", "active" ), 1 );
- state( element, 0, 1, 0 );
+ assert.equal( element.accordion( "option", "active" ), 1 );
+ state( assert, element, 0, 1, 0 );
} );
-test( "{ event: custom }", function() {
- expect( 11 );
+QUnit.test( "{ event: custom }", function( assert ) {
+ assert.expect( 11 );
var element = $( "#list1" ).accordion( {
event: "custom1 custom2"
} );
- state( element, 1, 0, 0 );
+ state( assert, element, 1, 0, 0 );
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom1" );
- equal( element.accordion( "option", "active" ), 1 );
- state( element, 0, 1, 0 );
+ assert.equal( element.accordion( "option", "active" ), 1 );
+ state( assert, element, 0, 1, 0 );
// Ensure default click handler isn't bound
element.find( ".ui-accordion-header" ).eq( 2 ).trigger( "click" );
- equal( element.accordion( "option", "active" ), 1 );
- state( element, 0, 1, 0 );
+ assert.equal( element.accordion( "option", "active" ), 1 );
+ state( assert, element, 0, 1, 0 );
element.find( ".ui-accordion-header" ).eq( 2 ).trigger( "custom2" );
- equal( element.accordion( "option", "active" ), 2 );
- state( element, 0, 0, 1 );
+ assert.equal( element.accordion( "option", "active" ), 2 );
+ state( assert, element, 0, 0, 1 );
element.accordion( "option", "event", "custom3" );
// Ensure old event handlers are unbound
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom1" );
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom2" );
- equal( element.accordion( "option", "active" ), 2 );
- state( element, 0, 0, 1 );
+ assert.equal( element.accordion( "option", "active" ), 2 );
+ state( assert, element, 0, 0, 1 );
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom3" );
- equal( element.accordion( "option", "active" ), 1 );
- state( element, 0, 1, 0 );
+ assert.equal( element.accordion( "option", "active" ), 1 );
+ state( assert, element, 0, 1, 0 );
} );
-test( "{ header: default }", function() {
- expect( 2 );
+QUnit.test( "{ header: default }", function( assert ) {
+ assert.expect( 2 );
// Default: > li > :first-child,> :not(li):even
// > :not(li):even
- state( $( "#list1" ).accordion(), 1, 0, 0 );
+ state( assert, $( "#list1" ).accordion(), 1, 0, 0 );
// > li > :first-child
- state( $( "#navigation" ).accordion(), 1, 0, 0 );
+ state( assert, $( "#navigation" ).accordion(), 1, 0, 0 );
} );
-test( "{ header: custom }", function( assert ) {
- expect( 6 );
+QUnit.test( "{ header: custom }", function( assert ) {
+ assert.expect( 6 );
var element = $( "#navigationWrapper" ).accordion( {
header: "h2"
} );
element.find( "h2" ).each( function() {
assert.hasClasses( this, "ui-accordion-header" );
} );
- equal( element.find( ".ui-accordion-header" ).length, 3 );
- state( element, 1, 0, 0 );
+ assert.equal( element.find( ".ui-accordion-header" ).length, 3 );
+ state( assert, element, 1, 0, 0 );
element.accordion( "option", "active", 2 );
- state( element, 0, 0, 1 );
+ state( assert, element, 0, 0, 1 );
} );
-test( "{ heightStyle: 'auto' }", function() {
- expect( 3 );
+QUnit.test( "{ heightStyle: 'auto' }", function( assert ) {
+ assert.expect( 3 );
var element = $( "#navigation" ).accordion( { heightStyle: "auto" } );
- equalHeight( element, 105 );
+ equalHeight( assert, element, 105 );
} );
-test( "{ heightStyle: 'content' }", function() {
- expect( 3 );
+QUnit.test( "{ heightStyle: 'content' }", function( assert ) {
+ assert.expect( 3 );
var element = $( "#navigation" ).accordion( { heightStyle: "content" } ),
sizes = element.find( ".ui-accordion-content" ).map( function() {
return $( this ).height();
} ).get();
- equal( sizes[ 0 ], 75 );
- equal( sizes[ 1 ], 105 );
- equal( sizes[ 2 ], 45 );
+ assert.equal( sizes[ 0 ], 75 );
+ assert.equal( sizes[ 1 ], 105 );
+ assert.equal( sizes[ 2 ], 45 );
} );
-test( "{ heightStyle: 'fill' }", function() {
- expect( 3 );
+QUnit.test( "{ heightStyle: 'fill' }", function( assert ) {
+ assert.expect( 3 );
$( "#navigationWrapper" ).height( 500 );
var element = $( "#navigation" ).accordion( { heightStyle: "fill" } );
- equalHeight( element, 455 );
+ equalHeight( assert, element, 455 );
} );
-test( "{ heightStyle: 'fill' } with sibling", function() {
- expect( 3 );
+QUnit.test( "{ heightStyle: 'fill' } with sibling", function( assert ) {
+ assert.expect( 3 );
$( "#navigationWrapper" ).height( 500 );
$( "<p>Lorem Ipsum</p>" )
.css( {
@@ -426,11 +433,11 @@ test( "{ heightStyle: 'fill' } with sibling", function() {
} )
.prependTo( "#navigationWrapper" );
var element = $( "#navigation" ).accordion( { heightStyle: "fill" } );
- equalHeight( element, 355 );
+ equalHeight( assert, element, 355 );
} );
-test( "{ heightStyle: 'fill' } with multiple siblings", function() {
- expect( 3 );
+QUnit.test( "{ heightStyle: 'fill' } with multiple siblings", function( assert ) {
+ assert.expect( 3 );
$( "#navigationWrapper" ).height( 500 );
$( "<p>Lorem Ipsum</p>" )
.css( {
@@ -455,15 +462,15 @@ test( "{ heightStyle: 'fill' } with multiple siblings", function() {
} )
.prependTo( "#navigationWrapper" );
var element = $( "#navigation" ).accordion( { heightStyle: "fill" } );
- equalHeight( element, 305 );
+ equalHeight( assert, element, 305 );
} );
-test( "{ icons: false }", function() {
- expect( 8 );
+QUnit.test( "{ icons: false }", function( assert ) {
+ assert.expect( 8 );
var element = $( "#list1" );
function icons( on ) {
- deepEqual( element.find( "span.ui-icon" ).length, on ? 3 : 0 );
- deepEqual( element.find( ".ui-accordion-header.ui-accordion-icons" ).length, on ? 3 : 0 );
+ assert.deepEqual( element.find( "span.ui-icon" ).length, on ? 3 : 0 );
+ assert.deepEqual( element.find( ".ui-accordion-header.ui-accordion-icons" ).length, on ? 3 : 0 );
}
element.accordion();
icons( true );
@@ -477,8 +484,8 @@ test( "{ icons: false }", function() {
icons( false );
} );
-test( "{ icons: hash }", function( assert ) {
- expect( 3 );
+QUnit.test( "{ icons: hash }", function( assert ) {
+ assert.expect( 3 );
var element = $( "#list1" ).accordion( {
icons: { activeHeader: "a1", header: "h1" }
} );