mirror of
https://github.com/tuxis-ie/nsedit.git
synced 2025-06-07 00:47:00 +03:00
Merge commit 'd32092c1f0
' as 'jquery-ui'
This commit is contained in:
commit
b23131fdc2
717 changed files with 518330 additions and 0 deletions
131
jquery-ui/tests/unit/accordion/accordion.html
Normal file
131
jquery-ui/tests/unit/accordion/accordion.html
Normal file
|
@ -0,0 +1,131 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>jQuery UI Accordion Test Suite</title>
|
||||
|
||||
<script src="../../../external/requirejs/require.js"></script>
|
||||
<script src="../../lib/css.js" data-modules="core accordion"></script>
|
||||
<script src="../../lib/bootstrap.js" data-widget="accordion"></script>
|
||||
<style>
|
||||
#list, #list1 *, #navigation, #navigation *, #collapsible, #collapsible * {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-size: 12px;
|
||||
line-height: 15px;
|
||||
}
|
||||
#collapsibleWrapper {
|
||||
width: 300px;
|
||||
float: left;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture">
|
||||
|
||||
<div id="list1" class="foo">
|
||||
<h3 class="bar">There is one obvious advantage:</h3>
|
||||
<div class="foo">
|
||||
<p>
|
||||
You've seen it coming!
|
||||
<br>
|
||||
Buy now and get nothing for free!
|
||||
<br>
|
||||
Well, at least no free beer. Perhaps a bear, if you can afford it.
|
||||
</p>
|
||||
</div>
|
||||
<h3 class="bar">Now that you've got...</h3>
|
||||
<div class="foo">
|
||||
<p>
|
||||
your bear, you have to admit it!
|
||||
<br>
|
||||
No, we aren't <a href="#">selling bears</a>.
|
||||
</p>
|
||||
<p>
|
||||
We could talk about renting one.
|
||||
</p>
|
||||
</div>
|
||||
<h3 class="bar">Rent one bear, ...</h3>
|
||||
<div class="foo">
|
||||
<p>
|
||||
get two for three beer.
|
||||
</p>
|
||||
<p>
|
||||
And now, for something completely different.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="navigationWrapper">
|
||||
<ul id="navigation">
|
||||
<li>
|
||||
<h2><a href="?p=1.1.1">Guitar</a></h2>
|
||||
<ul>
|
||||
<li><a href="?p=1.1.1.1">Electric</a></li>
|
||||
<li><a href="?p=1.1.1.2">Acoustic</a></li>
|
||||
<li><a href="?p=1.1.1.3">Amps</a></li>
|
||||
<li><a href="?p=1.1.1.4">Effects</a></li>
|
||||
<li><a href="?p=1.1.1.5">Accessories</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<h2><a href="?p=1.1.2"><span>Bass</span></a></h2>
|
||||
<ul>
|
||||
<li><a href="?p=1.1.2.1">Electric</a></li>
|
||||
<li><a href="?p=1.1.2.2">Acoustic</a></li>
|
||||
<li><a href="?p=1.1.2.3">Amps</a></li>
|
||||
<li><a href="?p=1.1.2.4">Effects</a></li>
|
||||
<li><a href="?p=1.1.2.5">Accessories</a></li>
|
||||
<li><a href="?p=1.1.2.5">Accessories</a></li>
|
||||
<li><a href="?p=1.1.2.5">Accessories</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<h2><a href="?p=1.1.3">Drums</a></h2>
|
||||
<ul>
|
||||
<li><a href="?p=1.1.3.2">Acoustic</a></li>
|
||||
<li><a href="?p=1.1.3.3">Electronic</a></li>
|
||||
<li><a href="?p=1.1.3.6">Accessories</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<dl id="accordion-dl">
|
||||
<dt>
|
||||
Accordion Header 1
|
||||
</dt>
|
||||
<dd>
|
||||
Accordion Content 1
|
||||
</dd>
|
||||
<dt>
|
||||
Accordion Header 2
|
||||
</dt>
|
||||
<dd>
|
||||
Accordion Content 2
|
||||
</dd>
|
||||
<dt>
|
||||
Accordion Header 3
|
||||
</dt>
|
||||
<dd>
|
||||
Accordion Content 3
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<div id="collapsibleWrapper">
|
||||
<div id="collapsible">
|
||||
<h3>Header</h3>
|
||||
<div>
|
||||
<p>
|
||||
The calculated height of this accordion should be the same
|
||||
regardless of whether the accordion was collapsed or not
|
||||
when the height was calculated.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
26
jquery-ui/tests/unit/accordion/all.html
Normal file
26
jquery-ui/tests/unit/accordion/all.html
Normal file
|
@ -0,0 +1,26 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>jQuery UI Accordion Test Suite</title>
|
||||
|
||||
<script src="../../../external/jquery/jquery.js"></script>
|
||||
|
||||
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
|
||||
<link rel="stylesheet" href="../../../external/qunit-composite/qunit-composite.css">
|
||||
<script src="../../../external/qunit/qunit.js"></script>
|
||||
<script src="../../../external/qunit-composite/qunit-composite.js"></script>
|
||||
<script src="../subsuite.js"></script>
|
||||
|
||||
<script>
|
||||
testAllVersions( "accordion" );
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture">
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
32
jquery-ui/tests/unit/accordion/common.js
vendored
Normal file
32
jquery-ui/tests/unit/accordion/common.js
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
define( [
|
||||
"lib/common",
|
||||
"ui/widgets/accordion"
|
||||
], function( common ) {
|
||||
|
||||
common.testWidget( "accordion", {
|
||||
defaults: {
|
||||
active: 0,
|
||||
animate: {},
|
||||
classes: {
|
||||
"ui-accordion-header": "ui-corner-top",
|
||||
"ui-accordion-header-collapsed": "ui-corner-all",
|
||||
"ui-accordion-content": "ui-corner-bottom"
|
||||
},
|
||||
collapsible: false,
|
||||
disabled: false,
|
||||
event: "click",
|
||||
header: "> li > :first-child, > :not(li):even",
|
||||
heightStyle: "auto",
|
||||
icons: {
|
||||
"activeHeader": "ui-icon-triangle-1-s",
|
||||
"header": "ui-icon-triangle-1-e"
|
||||
},
|
||||
|
||||
// Callbacks
|
||||
activate: null,
|
||||
beforeActivate: null,
|
||||
create: null
|
||||
}
|
||||
} );
|
||||
|
||||
} );
|
209
jquery-ui/tests/unit/accordion/core.js
vendored
Normal file
209
jquery-ui/tests/unit/accordion/core.js
vendored
Normal file
|
@ -0,0 +1,209 @@
|
|||
define( [
|
||||
"qunit",
|
||||
"jquery",
|
||||
"./helper",
|
||||
"ui/widgets/accordion"
|
||||
], function( QUnit, $, testHelper ) {
|
||||
|
||||
var setupTeardown = testHelper.setupTeardown,
|
||||
state = testHelper.state;
|
||||
|
||||
QUnit.module( "accordion: core", setupTeardown() );
|
||||
|
||||
$.each( { div: "#list1", ul: "#navigation", dl: "#accordion-dl" }, function( type, selector ) {
|
||||
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" );
|
||||
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" );
|
||||
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" );
|
||||
assert.deepEqual( element.find( ".ui-accordion-header" ).next().get(),
|
||||
element.find( ".ui-accordion-content" ).get(),
|
||||
"content panels come immediately after headers" );
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "handle click on header-descendant", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
var element = $( "#navigation" ).accordion();
|
||||
$( "#navigation h2:eq(1) a" ).trigger( "click" );
|
||||
state( assert, element, 0, 1, 0 );
|
||||
} );
|
||||
|
||||
QUnit.test( "accessibility", function( assert ) {
|
||||
assert.expect( 61 );
|
||||
var element = $( "#list1" ).accordion( {
|
||||
active: 1,
|
||||
collapsible: true
|
||||
} ),
|
||||
headers = element.find( ".ui-accordion-header" );
|
||||
|
||||
assert.equal( element.attr( "role" ), "tablist", "element role" );
|
||||
headers.each( function( i ) {
|
||||
var header = headers.eq( i ),
|
||||
panel = header.next();
|
||||
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" );
|
||||
} );
|
||||
|
||||
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 );
|
||||
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 );
|
||||
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 );
|
||||
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" );
|
||||
|
||||
} );
|
||||
|
||||
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;
|
||||
assert.equal( headers.filter( ".ui-state-focus" ).length, 0, "no headers focused on init" );
|
||||
headers.eq( 0 ).simulate( "focus" );
|
||||
setTimeout( step1 );
|
||||
|
||||
function step1() {
|
||||
assert.hasClasses( headers.eq( 0 ), "ui-state-focus", "first header has focus" );
|
||||
headers.eq( 0 ).simulate( "keydown", { keyCode: keyCode.DOWN } );
|
||||
setTimeout( step2 );
|
||||
}
|
||||
|
||||
// Support: IE 11 with jQuery 1.7 - 1.8 only
|
||||
// All of the setTimeouts() from keydowns aren't necessary with newer jQuery.
|
||||
// Only the explicit focus simulations require them.
|
||||
function step2() {
|
||||
assert.hasClasses( headers.eq( 1 ), "ui-state-focus", "DOWN moves focus to next header" );
|
||||
headers.eq( 1 ).simulate( "keydown", { keyCode: keyCode.RIGHT } );
|
||||
setTimeout( step3 );
|
||||
}
|
||||
|
||||
function step3() {
|
||||
assert.hasClasses( headers.eq( 2 ), "ui-state-focus", "RIGHT moves focus to next header" );
|
||||
headers.eq( 2 ).simulate( "keydown", { keyCode: keyCode.DOWN } );
|
||||
setTimeout( step4 );
|
||||
}
|
||||
|
||||
function step4() {
|
||||
assert.hasClasses( headers.eq( 0 ), "ui-state-focus", "DOWN wraps focus to first header" );
|
||||
headers.eq( 0 ).simulate( "keydown", { keyCode: keyCode.UP } );
|
||||
setTimeout( step5 );
|
||||
}
|
||||
|
||||
function step5() {
|
||||
assert.hasClasses( headers.eq( 2 ), "ui-state-focus", "UP wraps focus to last header" );
|
||||
headers.eq( 2 ).simulate( "keydown", { keyCode: keyCode.LEFT } );
|
||||
setTimeout( step6 );
|
||||
}
|
||||
|
||||
function step6() {
|
||||
assert.hasClasses( headers.eq( 1 ),
|
||||
"ui-state-focus", "LEFT moves focus to previous header" );
|
||||
headers.eq( 1 ).simulate( "keydown", { keyCode: keyCode.HOME } );
|
||||
setTimeout( step7 );
|
||||
}
|
||||
|
||||
function step7() {
|
||||
assert.hasClasses( headers.eq( 0 ), "ui-state-focus", "HOME moves focus to first header" );
|
||||
headers.eq( 0 ).simulate( "keydown", { keyCode: keyCode.END } );
|
||||
setTimeout( step8 );
|
||||
}
|
||||
|
||||
function step8() {
|
||||
assert.hasClasses( headers.eq( 2 ), "ui-state-focus", "END moves focus to last header" );
|
||||
headers.eq( 2 ).simulate( "keydown", { keyCode: keyCode.ENTER } );
|
||||
setTimeout( step9 );
|
||||
}
|
||||
|
||||
function step9() {
|
||||
assert.equal( element.accordion( "option", "active" ), 2, "ENTER activates panel" );
|
||||
headers.eq( 1 ).simulate( "keydown", { keyCode: keyCode.SPACE } );
|
||||
setTimeout( step10 );
|
||||
}
|
||||
|
||||
function step10() {
|
||||
assert.equal( element.accordion( "option", "active" ), 1, "SPACE activates panel" );
|
||||
anchor.simulate( "focus" );
|
||||
setTimeout( step11 );
|
||||
}
|
||||
|
||||
function step11() {
|
||||
assert.lacksClasses( headers.eq( 1 ), "ui-state-focus",
|
||||
"header loses focus when focusing inside the panel" );
|
||||
anchor.simulate( "keydown", { keyCode: keyCode.UP, ctrlKey: true } );
|
||||
setTimeout( step12 );
|
||||
}
|
||||
|
||||
function step12() {
|
||||
assert.hasClasses( headers.eq( 1 ), "ui-state-focus", "CTRL+UP moves focus to header" );
|
||||
ready();
|
||||
}
|
||||
} );
|
||||
|
||||
} );
|
169
jquery-ui/tests/unit/accordion/events.js
vendored
Normal file
169
jquery-ui/tests/unit/accordion/events.js
vendored
Normal file
|
@ -0,0 +1,169 @@
|
|||
define( [
|
||||
"qunit",
|
||||
"jquery",
|
||||
"./helper",
|
||||
"ui/widgets/accordion"
|
||||
], function( QUnit, $, testHelper ) {
|
||||
|
||||
var setupTeardown = testHelper.setupTeardown,
|
||||
state = testHelper.state;
|
||||
|
||||
QUnit.module( "accordion: events", setupTeardown() );
|
||||
|
||||
QUnit.test( "create", function( assert ) {
|
||||
assert.expect( 10 );
|
||||
|
||||
var element = $( "#list1" ),
|
||||
headers = element.children( "h3" ),
|
||||
contents = headers.next();
|
||||
|
||||
element.accordion( {
|
||||
create: function( event, ui ) {
|
||||
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" );
|
||||
|
||||
element.accordion( {
|
||||
active: 2,
|
||||
create: function( event, ui ) {
|
||||
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" );
|
||||
|
||||
element.accordion( {
|
||||
active: false,
|
||||
collapsible: true,
|
||||
create: function( event, ui ) {
|
||||
assert.equal( ui.header.length, 0, "header length" );
|
||||
assert.equal( ui.panel.length, 0, "panel length" );
|
||||
}
|
||||
} );
|
||||
element.accordion( "destroy" );
|
||||
} );
|
||||
|
||||
QUnit.test( "beforeActivate", function( assert ) {
|
||||
assert.expect( 38 );
|
||||
var element = $( "#list1" ).accordion( {
|
||||
active: false,
|
||||
collapsible: true
|
||||
} ),
|
||||
headers = element.find( ".ui-accordion-header" ),
|
||||
content = element.find( ".ui-accordion-content" );
|
||||
|
||||
element.one( "accordionbeforeactivate", function( event, ui ) {
|
||||
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( assert, element, 1, 0, 0 );
|
||||
|
||||
element.one( "accordionbeforeactivate", function( event, ui ) {
|
||||
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( assert, element, 0, 1, 0 );
|
||||
|
||||
element.one( "accordionbeforeactivate", function( event, ui ) {
|
||||
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( assert, element, 0, 0, 0 );
|
||||
|
||||
element.one( "accordionbeforeactivate", function( event, ui ) {
|
||||
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( assert, element, 0, 0, 0 );
|
||||
} );
|
||||
element.accordion( "option", "active", 2 );
|
||||
state( assert, element, 0, 0, 0 );
|
||||
} );
|
||||
|
||||
QUnit.test( "activate", function( assert ) {
|
||||
assert.expect( 21 );
|
||||
var element = $( "#list1" ).accordion( {
|
||||
active: false,
|
||||
collapsible: true
|
||||
} ),
|
||||
headers = element.find( ".ui-accordion-header" ),
|
||||
content = element.find( ".ui-accordion-content" );
|
||||
|
||||
element.one( "accordionactivate", function( event, ui ) {
|
||||
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 ) {
|
||||
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 ) {
|
||||
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 ) {
|
||||
assert.ok( true );
|
||||
event.preventDefault();
|
||||
} );
|
||||
element.one( "accordionactivate", function() {
|
||||
assert.ok( false );
|
||||
} );
|
||||
element.accordion( "option", "active", 1 );
|
||||
} );
|
||||
|
||||
} );
|
36
jquery-ui/tests/unit/accordion/helper.js
vendored
Normal file
36
jquery-ui/tests/unit/accordion/helper.js
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
define( [
|
||||
"qunit",
|
||||
"jquery",
|
||||
"lib/helper",
|
||||
"ui/widgets/accordion"
|
||||
], function( QUnit, $, helper ) {
|
||||
|
||||
return $.extend( helper, {
|
||||
equalHeight: function( assert, accordion, height ) {
|
||||
accordion.find( ".ui-accordion-content" ).each( function() {
|
||||
assert.equal( $( this ).outerHeight(), height );
|
||||
} );
|
||||
},
|
||||
|
||||
setupTeardown: function() {
|
||||
var animate = $.ui.accordion.prototype.options.animate;
|
||||
return {
|
||||
setup: function() {
|
||||
$.ui.accordion.prototype.options.animate = false;
|
||||
},
|
||||
teardown: function() {
|
||||
$.ui.accordion.prototype.options.animate = animate;
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
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();
|
||||
assert.deepEqual( actual, expected );
|
||||
}
|
||||
} );
|
||||
|
||||
} );
|
138
jquery-ui/tests/unit/accordion/methods.js
vendored
Normal file
138
jquery-ui/tests/unit/accordion/methods.js
vendored
Normal file
|
@ -0,0 +1,138 @@
|
|||
define( [
|
||||
"qunit",
|
||||
"jquery",
|
||||
"./helper",
|
||||
"ui/widgets/accordion"
|
||||
], function( QUnit, $, testHelper ) {
|
||||
|
||||
var equalHeight = testHelper.equalHeight,
|
||||
setupTeardown = testHelper.setupTeardown,
|
||||
state = testHelper.state;
|
||||
|
||||
QUnit.module( "accordion: methods", setupTeardown() );
|
||||
|
||||
QUnit.test( "destroy", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
assert.domEqual( "#list1", function() {
|
||||
$( "#list1" ).accordion().accordion( "destroy" );
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "enable/disable", function( assert ) {
|
||||
assert.expect( 7 );
|
||||
var element = $( "#list1" ).accordion();
|
||||
state( assert, element, 1, 0, 0 );
|
||||
element.accordion( "disable" );
|
||||
|
||||
assert.hasClasses( element, "ui-state-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( assert, element, 1, 0, 0 );
|
||||
|
||||
// Option still works
|
||||
element.accordion( "option", "active", 1 );
|
||||
state( assert, element, 0, 1, 0 );
|
||||
element.accordion( "enable" );
|
||||
element.accordion( "option", "active", 2 );
|
||||
state( assert, element, 0, 0, 1 );
|
||||
} );
|
||||
|
||||
QUnit.test( "refresh", function( assert ) {
|
||||
assert.expect( 19 );
|
||||
var element = $( "#navigation" )
|
||||
.parent()
|
||||
.height( 300 )
|
||||
.end()
|
||||
.accordion( {
|
||||
heightStyle: "fill"
|
||||
} );
|
||||
equalHeight( assert, element, 255 );
|
||||
|
||||
element.parent().height( 500 );
|
||||
element.accordion( "refresh" );
|
||||
equalHeight( assert, element, 455 );
|
||||
|
||||
element = $( "#list1" );
|
||||
element.accordion();
|
||||
state( assert, element, 1, 0, 0 );
|
||||
|
||||
// Disable panel via markup
|
||||
element.find( "h3.bar" ).eq( 1 ).addClass( "ui-state-disabled" );
|
||||
element.accordion( "refresh" );
|
||||
state( assert, element, 1, 0, 0 );
|
||||
|
||||
// Don't add multiple icons
|
||||
element.accordion( "refresh" );
|
||||
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( assert, element, 1, 0, 0, 0 );
|
||||
|
||||
// Remove all tabs
|
||||
element.find( "h3.bar, div.foo" ).remove();
|
||||
element.accordion( "refresh" );
|
||||
state( assert, element );
|
||||
assert.equal( element.accordion( "option", "active" ), false, "no active accordion panel" );
|
||||
|
||||
// Add panels
|
||||
element
|
||||
.append( "<h3 class='bar' id='new_2'>new 2</h3>" )
|
||||
.append( "<div class='foo' id='new_2_panel'>new 2</div>" )
|
||||
.append( "<h3 class='bar' id='new_3'>new 3</h3>" )
|
||||
.append( "<div class='foo' id='new_3_panel'>new 3</div>" )
|
||||
.append( "<h3 class='bar' id='new_4'>new 4</h3>" )
|
||||
.append( "<div class='foo' id='new_4_panel'>new 4</div>" )
|
||||
.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( assert, element, 1, 0, 0, 0 );
|
||||
|
||||
// Activate third tab
|
||||
element.accordion( "option", "active", 2 );
|
||||
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( 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( 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( assert, element, 1 );
|
||||
|
||||
// Collapse all panels
|
||||
element.accordion( "option", {
|
||||
collapsible: true,
|
||||
active: false
|
||||
} );
|
||||
state( assert, element, 0 );
|
||||
element.accordion( "refresh" );
|
||||
state( assert, element, 0 );
|
||||
} );
|
||||
|
||||
QUnit.test( "widget", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
var element = $( "#list1" ).accordion(),
|
||||
widgetElement = element.accordion( "widget" );
|
||||
assert.equal( widgetElement.length, 1, "one element" );
|
||||
assert.strictEqual( widgetElement[ 0 ], element[ 0 ], "same element" );
|
||||
} );
|
||||
|
||||
} );
|
498
jquery-ui/tests/unit/accordion/options.js
vendored
Normal file
498
jquery-ui/tests/unit/accordion/options.js
vendored
Normal file
|
@ -0,0 +1,498 @@
|
|||
define( [
|
||||
"qunit",
|
||||
"jquery",
|
||||
"./helper",
|
||||
"ui/widgets/accordion"
|
||||
], function( QUnit, $, testHelper ) {
|
||||
|
||||
var equalHeight = testHelper.equalHeight,
|
||||
setupTeardown = testHelper.setupTeardown,
|
||||
state = testHelper.state;
|
||||
|
||||
QUnit.module( "accordion: options", setupTeardown() );
|
||||
|
||||
QUnit.test( "{ active: default }", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
var element = $( "#list1" ).accordion();
|
||||
assert.equal( element.accordion( "option", "active" ), 0 );
|
||||
state( assert, element, 1, 0, 0 );
|
||||
} );
|
||||
|
||||
QUnit.test( "{ active: null }", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
var element = $( "#list1" ).accordion( {
|
||||
active: null
|
||||
} );
|
||||
assert.equal( element.accordion( "option", "active" ), 0 );
|
||||
state( assert, element, 1, 0, 0 );
|
||||
} );
|
||||
|
||||
QUnit.test( "{ active: false }", function( assert ) {
|
||||
assert.expect( 7 );
|
||||
var element = $( "#list1" ).accordion( {
|
||||
active: false,
|
||||
collapsible: true
|
||||
} );
|
||||
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( assert, element, 1, 0, 0 );
|
||||
assert.equal( element.accordion( "option", "active" ), 0 );
|
||||
|
||||
element.accordion( "destroy" );
|
||||
element.accordion( {
|
||||
active: false
|
||||
} );
|
||||
state( assert, element, 1, 0, 0 );
|
||||
assert.strictEqual( element.accordion( "option", "active" ), 0 );
|
||||
} );
|
||||
|
||||
// http://bugs.jqueryui.com/ticket/11938
|
||||
QUnit.test( "{ active: false, collapsible: true }", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
var element = $( "#collapsible" ).accordion(),
|
||||
height = element.outerHeight();
|
||||
|
||||
element
|
||||
.accordion( "destroy" )
|
||||
.accordion( {
|
||||
active: false,
|
||||
collapsible: true
|
||||
} )
|
||||
.accordion( "option", "active", 0 );
|
||||
assert.equal( element.outerHeight(), height );
|
||||
} );
|
||||
|
||||
QUnit.test( "{ active: Number }", function( assert ) {
|
||||
assert.expect( 8 );
|
||||
var element = $( "#list1" ).accordion( {
|
||||
active: 2
|
||||
} );
|
||||
assert.equal( element.accordion( "option", "active" ), 2 );
|
||||
state( assert, element, 0, 0, 1 );
|
||||
|
||||
element.accordion( "option", "active", 0 );
|
||||
assert.equal( element.accordion( "option", "active" ), 0 );
|
||||
state( assert, element, 1, 0, 0 );
|
||||
|
||||
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "click" );
|
||||
assert.equal( element.accordion( "option", "active" ), 1 );
|
||||
state( assert, element, 0, 1, 0 );
|
||||
|
||||
element.accordion( "option", "active", 10 );
|
||||
assert.equal( element.accordion( "option", "active" ), 1 );
|
||||
state( assert, element, 0, 1, 0 );
|
||||
} );
|
||||
|
||||
QUnit.test( "{ active: -Number }", function( assert ) {
|
||||
assert.expect( 8 );
|
||||
var element = $( "#list1" ).accordion( {
|
||||
active: -1
|
||||
} );
|
||||
assert.equal( element.accordion( "option", "active" ), 2 );
|
||||
state( assert, element, 0, 0, 1 );
|
||||
|
||||
element.accordion( "option", "active", -2 );
|
||||
assert.equal( element.accordion( "option", "active" ), 1 );
|
||||
state( assert, element, 0, 1, 0 );
|
||||
|
||||
element.accordion( "option", "active", -10 );
|
||||
assert.equal( element.accordion( "option", "active" ), 1 );
|
||||
state( assert, element, 0, 1, 0 );
|
||||
|
||||
element.accordion( "option", "active", -3 );
|
||||
assert.equal( element.accordion( "option", "active" ), 0 );
|
||||
state( assert, element, 1, 0, 0 );
|
||||
} );
|
||||
|
||||
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() {
|
||||
assert.ok( false, ".animate() called" );
|
||||
};
|
||||
|
||||
assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
|
||||
element.accordion( "option", "active", 1 );
|
||||
assert.ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
|
||||
assert.ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
|
||||
$.fn.animate = animate;
|
||||
} );
|
||||
|
||||
QUnit.test( "{ animate: Number }", function( assert ) {
|
||||
var ready = assert.async();
|
||||
assert.expect( 7 );
|
||||
var element = $( "#list1" ).accordion( {
|
||||
animate: 100
|
||||
} ),
|
||||
panels = element.find( ".ui-accordion-content" ),
|
||||
animate = $.fn.animate;
|
||||
|
||||
// Called twice (both panels)
|
||||
$.fn.animate = function( props, options ) {
|
||||
assert.equal( options.duration, 100, "correct duration" );
|
||||
assert.equal( options.easing, undefined, "default easing" );
|
||||
animate.apply( this, arguments );
|
||||
};
|
||||
|
||||
assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
|
||||
element.accordion( "option", "active", 1 );
|
||||
panels.promise().done( function() {
|
||||
assert.ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
|
||||
assert.ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
|
||||
$.fn.animate = animate;
|
||||
ready();
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "{ animate: String }", function( assert ) {
|
||||
var ready = assert.async();
|
||||
assert.expect( 7 );
|
||||
var element = $( "#list1" ).accordion( {
|
||||
animate: "linear"
|
||||
} ),
|
||||
panels = element.find( ".ui-accordion-content" ),
|
||||
animate = $.fn.animate;
|
||||
|
||||
// Called twice (both panels)
|
||||
$.fn.animate = function( props, options ) {
|
||||
assert.equal( options.duration, undefined, "default duration" );
|
||||
assert.equal( options.easing, "linear", "correct easing" );
|
||||
animate.apply( this, arguments );
|
||||
};
|
||||
|
||||
assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
|
||||
element.accordion( "option", "active", 1 );
|
||||
panels.promise().done( function() {
|
||||
assert.ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
|
||||
assert.ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
|
||||
$.fn.animate = animate;
|
||||
ready();
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "{ animate: {} }", function( assert ) {
|
||||
var ready = assert.async();
|
||||
assert.expect( 7 );
|
||||
var element = $( "#list1" ).accordion( {
|
||||
animate: {}
|
||||
} ),
|
||||
panels = element.find( ".ui-accordion-content" ),
|
||||
animate = $.fn.animate;
|
||||
|
||||
// Called twice (both panels)
|
||||
$.fn.animate = function( props, options ) {
|
||||
assert.equal( options.duration, undefined, "default duration" );
|
||||
assert.equal( options.easing, undefined, "default easing" );
|
||||
animate.apply( this, arguments );
|
||||
};
|
||||
|
||||
assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
|
||||
element.accordion( "option", "active", 1 );
|
||||
panels.promise().done( function() {
|
||||
assert.ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
|
||||
assert.ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
|
||||
$.fn.animate = animate;
|
||||
ready();
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "{ animate: { duration, easing } }", function( assert ) {
|
||||
var ready = assert.async();
|
||||
assert.expect( 7 );
|
||||
var element = $( "#list1" ).accordion( {
|
||||
animate: { duration: 100, easing: "linear" }
|
||||
} ),
|
||||
panels = element.find( ".ui-accordion-content" ),
|
||||
animate = $.fn.animate;
|
||||
|
||||
// Called twice (both panels)
|
||||
$.fn.animate = function( props, options ) {
|
||||
assert.equal( options.duration, 100, "correct duration" );
|
||||
assert.equal( options.easing, "linear", "correct easing" );
|
||||
animate.apply( this, arguments );
|
||||
};
|
||||
|
||||
assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
|
||||
element.accordion( "option", "active", 1 );
|
||||
panels.promise().done( function() {
|
||||
assert.ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
|
||||
assert.ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
|
||||
$.fn.animate = animate;
|
||||
ready();
|
||||
} );
|
||||
} );
|
||||
|
||||
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" }
|
||||
} ),
|
||||
panels = element.find( ".ui-accordion-content" ),
|
||||
animate = $.fn.animate;
|
||||
|
||||
// Called twice (both panels)
|
||||
$.fn.animate = function( props, options ) {
|
||||
assert.equal( options.duration, 100, "correct duration" );
|
||||
assert.equal( options.easing, "linear", "correct easing" );
|
||||
animate.apply( this, arguments );
|
||||
};
|
||||
|
||||
assert.ok( panels.eq( 1 ).is( ":visible" ), "first panel visible" );
|
||||
element.accordion( "option", "active", 0 );
|
||||
panels.promise().done( function() {
|
||||
assert.ok( panels.eq( 1 ).is( ":hidden" ), "first panel hidden" );
|
||||
assert.ok( panels.eq( 0 ).is( ":visible" ), "second panel visible" );
|
||||
$.fn.animate = animate;
|
||||
ready();
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "{ animate: { duration, easing, down } }, animate down", function( assert ) {
|
||||
var ready = assert.async();
|
||||
assert.expect( 7 );
|
||||
var element = $( "#list1" ).accordion( {
|
||||
active: 1,
|
||||
animate: {
|
||||
duration: 100,
|
||||
easing: "linear",
|
||||
down: {
|
||||
easing: "swing"
|
||||
}
|
||||
}
|
||||
} ),
|
||||
panels = element.find( ".ui-accordion-content" ),
|
||||
animate = $.fn.animate;
|
||||
|
||||
// Called twice (both panels)
|
||||
$.fn.animate = function( props, options ) {
|
||||
assert.equal( options.duration, 100, "correct duration" );
|
||||
assert.equal( options.easing, "swing", "correct easing" );
|
||||
animate.apply( this, arguments );
|
||||
};
|
||||
|
||||
assert.ok( panels.eq( 1 ).is( ":visible" ), "first panel visible" );
|
||||
element.accordion( "option", "active", 0 );
|
||||
panels.promise().done( function() {
|
||||
assert.ok( panels.eq( 1 ).is( ":hidden" ), "first panel hidden" );
|
||||
assert.ok( panels.eq( 0 ).is( ":visible" ), "second panel visible" );
|
||||
$.fn.animate = animate;
|
||||
ready();
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "{ collapsible: false }", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
var element = $( "#list1" ).accordion( {
|
||||
active: 1
|
||||
} );
|
||||
element.accordion( "option", "active", false );
|
||||
assert.equal( element.accordion( "option", "active" ), 1 );
|
||||
state( assert, element, 0, 1, 0 );
|
||||
|
||||
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "click" );
|
||||
assert.equal( element.accordion( "option", "active" ), 1 );
|
||||
state( assert, element, 0, 1, 0 );
|
||||
} );
|
||||
|
||||
QUnit.test( "{ collapsible: true }", function( assert ) {
|
||||
assert.expect( 6 );
|
||||
var element = $( "#list1" ).accordion( {
|
||||
active: 1,
|
||||
collapsible: true
|
||||
} );
|
||||
|
||||
element.accordion( "option", "active", false );
|
||||
assert.equal( element.accordion( "option", "active" ), false );
|
||||
state( assert, element, 0, 0, 0 );
|
||||
|
||||
element.accordion( "option", "active", 1 );
|
||||
assert.equal( element.accordion( "option", "active" ), 1 );
|
||||
state( assert, element, 0, 1, 0 );
|
||||
|
||||
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "click" );
|
||||
assert.equal( element.accordion( "option", "active" ), false );
|
||||
state( assert, element, 0, 0, 0 );
|
||||
} );
|
||||
|
||||
QUnit.test( "{ event: null }", function( assert ) {
|
||||
assert.expect( 5 );
|
||||
var element = $( "#list1" ).accordion( {
|
||||
event: null
|
||||
} );
|
||||
state( assert, element, 1, 0, 0 );
|
||||
|
||||
element.accordion( "option", "active", 1 );
|
||||
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" );
|
||||
assert.equal( element.accordion( "option", "active" ), 1 );
|
||||
state( assert, element, 0, 1, 0 );
|
||||
} );
|
||||
|
||||
QUnit.test( "{ event: custom }", function( assert ) {
|
||||
assert.expect( 11 );
|
||||
var element = $( "#list1" ).accordion( {
|
||||
event: "custom1 custom2"
|
||||
} );
|
||||
state( assert, element, 1, 0, 0 );
|
||||
|
||||
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom1" );
|
||||
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" );
|
||||
assert.equal( element.accordion( "option", "active" ), 1 );
|
||||
state( assert, element, 0, 1, 0 );
|
||||
|
||||
element.find( ".ui-accordion-header" ).eq( 2 ).trigger( "custom2" );
|
||||
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" );
|
||||
assert.equal( element.accordion( "option", "active" ), 2 );
|
||||
state( assert, element, 0, 0, 1 );
|
||||
|
||||
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom3" );
|
||||
assert.equal( element.accordion( "option", "active" ), 1 );
|
||||
state( assert, element, 0, 1, 0 );
|
||||
} );
|
||||
|
||||
QUnit.test( "{ header: default }", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
// Default: > li > :first-child,> :not(li):even
|
||||
// > :not(li):even
|
||||
state( assert, $( "#list1" ).accordion(), 1, 0, 0 );
|
||||
|
||||
// > li > :first-child
|
||||
state( assert, $( "#navigation" ).accordion(), 1, 0, 0 );
|
||||
} );
|
||||
|
||||
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" );
|
||||
} );
|
||||
assert.equal( element.find( ".ui-accordion-header" ).length, 3 );
|
||||
state( assert, element, 1, 0, 0 );
|
||||
element.accordion( "option", "active", 2 );
|
||||
state( assert, element, 0, 0, 1 );
|
||||
} );
|
||||
|
||||
QUnit.test( "{ heightStyle: 'auto' }", function( assert ) {
|
||||
assert.expect( 3 );
|
||||
var element = $( "#navigation" ).accordion( { heightStyle: "auto" } );
|
||||
equalHeight( assert, element, 105 );
|
||||
} );
|
||||
|
||||
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();
|
||||
assert.equal( sizes[ 0 ], 75 );
|
||||
assert.equal( sizes[ 1 ], 105 );
|
||||
assert.equal( sizes[ 2 ], 45 );
|
||||
} );
|
||||
|
||||
QUnit.test( "{ heightStyle: 'fill' }", function( assert ) {
|
||||
assert.expect( 3 );
|
||||
$( "#navigationWrapper" ).height( 500 );
|
||||
var element = $( "#navigation" ).accordion( { heightStyle: "fill" } );
|
||||
equalHeight( assert, element, 455 );
|
||||
} );
|
||||
|
||||
QUnit.test( "{ heightStyle: 'fill' } with sibling", function( assert ) {
|
||||
assert.expect( 3 );
|
||||
$( "#navigationWrapper" ).height( 500 );
|
||||
$( "<p>Lorem Ipsum</p>" )
|
||||
.css( {
|
||||
height: 50,
|
||||
marginTop: 20,
|
||||
marginBottom: 30
|
||||
} )
|
||||
.prependTo( "#navigationWrapper" );
|
||||
var element = $( "#navigation" ).accordion( { heightStyle: "fill" } );
|
||||
equalHeight( assert, element, 355 );
|
||||
} );
|
||||
|
||||
QUnit.test( "{ heightStyle: 'fill' } with multiple siblings", function( assert ) {
|
||||
assert.expect( 3 );
|
||||
$( "#navigationWrapper" ).height( 500 );
|
||||
$( "<p>Lorem Ipsum</p>" )
|
||||
.css( {
|
||||
height: 50,
|
||||
marginTop: 20,
|
||||
marginBottom: 30
|
||||
} )
|
||||
.prependTo( "#navigationWrapper" );
|
||||
$( "<p>Lorem Ipsum</p>" )
|
||||
.css( {
|
||||
height: 50,
|
||||
marginTop: 20,
|
||||
marginBottom: 30,
|
||||
position: "absolute"
|
||||
} )
|
||||
.prependTo( "#navigationWrapper" );
|
||||
$( "<p>Lorem Ipsum</p>" )
|
||||
.css( {
|
||||
height: 25,
|
||||
marginTop: 10,
|
||||
marginBottom: 15
|
||||
} )
|
||||
.prependTo( "#navigationWrapper" );
|
||||
var element = $( "#navigation" ).accordion( { heightStyle: "fill" } );
|
||||
equalHeight( assert, element, 305 );
|
||||
} );
|
||||
|
||||
QUnit.test( "{ icons: false }", function( assert ) {
|
||||
assert.expect( 8 );
|
||||
var element = $( "#list1" );
|
||||
function icons( on ) {
|
||||
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 );
|
||||
element.accordion( "destroy" ).accordion( {
|
||||
icons: false
|
||||
} );
|
||||
icons( false );
|
||||
element.accordion( "option", "icons", { header: "foo", activeHeader: "bar" } );
|
||||
icons( true );
|
||||
element.accordion( "option", "icons", false );
|
||||
icons( false );
|
||||
} );
|
||||
|
||||
QUnit.test( "{ icons: hash }", function( assert ) {
|
||||
assert.expect( 3 );
|
||||
var element = $( "#list1" ).accordion( {
|
||||
icons: { activeHeader: "a1", header: "h1" }
|
||||
} );
|
||||
assert.hasClasses( element.find( ".ui-accordion-header.ui-state-active span.ui-icon" ), "a1" );
|
||||
element.accordion( "option", "icons", { activeHeader: "a2", header: "h2" } );
|
||||
assert.lacksClasses( element.find( ".ui-accordion-header.ui-state-active span.ui-icon" ), "a1" );
|
||||
assert.hasClasses( element.find( ".ui-accordion-header.ui-state-active span.ui-icon" ), "a2" );
|
||||
} );
|
||||
|
||||
} );
|
Loading…
Add table
Add a link
Reference in a new issue