2015-04-03 19:24:09 +00:00
|
|
|
define( [
|
2016-04-03 14:37:27 +00:00
|
|
|
"qunit",
|
2015-04-03 19:24:09 +00:00
|
|
|
"jquery",
|
2015-04-07 14:55:52 +00:00
|
|
|
"./helper",
|
2015-07-15 01:54:33 +00:00
|
|
|
"ui/widgets/accordion"
|
2016-04-03 14:37:27 +00:00
|
|
|
], function( QUnit, $, testHelper ) {
|
2021-06-06 22:58:12 +00:00
|
|
|
"use strict";
|
2009-02-02 14:36:08 +00:00
|
|
|
|
2015-04-07 14:30:07 +00:00
|
|
|
var equalHeight = testHelper.equalHeight,
|
2020-05-16 07:16:24 +00:00
|
|
|
beforeAfterEach = testHelper.beforeAfterEach,
|
2015-04-07 14:30:07 +00:00
|
|
|
state = testHelper.state;
|
2012-04-19 15:37:33 +00:00
|
|
|
|
2020-05-16 07:16:24 +00:00
|
|
|
QUnit.module( "accordion: options", beforeAfterEach() );
|
2009-02-02 14:36:08 +00:00
|
|
|
|
2016-04-03 14:37:27 +00:00
|
|
|
QUnit.test( "{ active: default }", function( assert ) {
|
|
|
|
assert.expect( 2 );
|
2011-04-15 15:29:26 +00:00
|
|
|
var element = $( "#list1" ).accordion();
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.equal( element.accordion( "option", "active" ), 0 );
|
|
|
|
state( assert, element, 1, 0, 0 );
|
2015-08-21 04:12:07 +00:00
|
|
|
} );
|
2009-02-03 08:23:48 +00:00
|
|
|
|
2016-04-03 14:37:27 +00:00
|
|
|
QUnit.test( "{ active: null }", function( assert ) {
|
|
|
|
assert.expect( 2 );
|
2015-08-21 04:12:07 +00:00
|
|
|
var element = $( "#list1" ).accordion( {
|
2012-10-17 15:35:27 +00:00
|
|
|
active: null
|
2015-08-21 04:12:07 +00:00
|
|
|
} );
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.equal( element.accordion( "option", "active" ), 0 );
|
|
|
|
state( assert, element, 1, 0, 0 );
|
2015-08-21 04:12:07 +00:00
|
|
|
} );
|
2012-10-17 15:35:27 +00:00
|
|
|
|
2016-04-03 14:37:27 +00:00
|
|
|
QUnit.test( "{ active: false }", function( assert ) {
|
|
|
|
assert.expect( 7 );
|
2015-08-21 04:12:07 +00:00
|
|
|
var element = $( "#list1" ).accordion( {
|
2009-02-03 08:23:48 +00:00
|
|
|
active: false,
|
|
|
|
collapsible: true
|
2015-08-21 04:12:07 +00:00
|
|
|
} );
|
2016-04-03 14:37:27 +00:00
|
|
|
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 );
|
2011-01-25 00:20:09 +00:00
|
|
|
|
2011-04-15 15:29:26 +00:00
|
|
|
element.accordion( "option", "collapsible", false );
|
2016-04-03 14:37:27 +00:00
|
|
|
state( assert, element, 1, 0, 0 );
|
|
|
|
assert.equal( element.accordion( "option", "active" ), 0 );
|
2011-02-03 14:54:11 +00:00
|
|
|
|
2011-04-15 15:29:26 +00:00
|
|
|
element.accordion( "destroy" );
|
2015-08-21 04:12:07 +00:00
|
|
|
element.accordion( {
|
2011-02-03 14:54:11 +00:00
|
|
|
active: false
|
2015-08-21 04:12:07 +00:00
|
|
|
} );
|
2016-04-03 14:37:27 +00:00
|
|
|
state( assert, element, 1, 0, 0 );
|
|
|
|
assert.strictEqual( element.accordion( "option", "active" ), 0 );
|
2015-08-21 04:12:07 +00:00
|
|
|
} );
|
2009-02-03 08:23:48 +00:00
|
|
|
|
2024-04-26 14:25:34 +00:00
|
|
|
// https://bugs.jqueryui.com/ticket/11938
|
2016-04-03 14:37:27 +00:00
|
|
|
QUnit.test( "{ active: false, collapsible: true }", function( assert ) {
|
|
|
|
assert.expect( 1 );
|
2015-04-13 02:17:16 +00:00
|
|
|
var element = $( "#collapsible" ).accordion(),
|
|
|
|
height = element.outerHeight();
|
|
|
|
|
|
|
|
element
|
|
|
|
.accordion( "destroy" )
|
|
|
|
.accordion( {
|
|
|
|
active: false,
|
|
|
|
collapsible: true
|
|
|
|
} )
|
|
|
|
.accordion( "option", "active", 0 );
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.equal( element.outerHeight(), height );
|
2015-04-13 02:17:16 +00:00
|
|
|
} );
|
|
|
|
|
2016-04-03 14:37:27 +00:00
|
|
|
QUnit.test( "{ active: Number }", function( assert ) {
|
|
|
|
assert.expect( 8 );
|
2015-08-21 04:12:07 +00:00
|
|
|
var element = $( "#list1" ).accordion( {
|
2011-01-25 00:20:09 +00:00
|
|
|
active: 2
|
2015-08-21 04:12:07 +00:00
|
|
|
} );
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.equal( element.accordion( "option", "active" ), 2 );
|
|
|
|
state( assert, element, 0, 0, 1 );
|
2009-08-11 00:45:01 +00:00
|
|
|
|
2011-04-15 15:29:26 +00:00
|
|
|
element.accordion( "option", "active", 0 );
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.equal( element.accordion( "option", "active" ), 0 );
|
|
|
|
state( assert, element, 1, 0, 0 );
|
2009-08-11 00:45:01 +00:00
|
|
|
|
2015-05-14 01:52:09 +00:00
|
|
|
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "click" );
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.equal( element.accordion( "option", "active" ), 1 );
|
|
|
|
state( assert, element, 0, 1, 0 );
|
2009-08-11 00:45:01 +00:00
|
|
|
|
2011-04-15 15:29:26 +00:00
|
|
|
element.accordion( "option", "active", 10 );
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.equal( element.accordion( "option", "active" ), 1 );
|
|
|
|
state( assert, element, 0, 1, 0 );
|
2015-08-21 04:12:07 +00:00
|
|
|
} );
|
2009-02-03 08:23:48 +00:00
|
|
|
|
2016-04-03 14:37:27 +00:00
|
|
|
QUnit.test( "{ active: -Number }", function( assert ) {
|
|
|
|
assert.expect( 8 );
|
2015-08-21 04:12:07 +00:00
|
|
|
var element = $( "#list1" ).accordion( {
|
2012-10-24 15:11:47 +00:00
|
|
|
active: -1
|
2015-08-21 04:12:07 +00:00
|
|
|
} );
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.equal( element.accordion( "option", "active" ), 2 );
|
|
|
|
state( assert, element, 0, 0, 1 );
|
2012-10-24 15:11:47 +00:00
|
|
|
|
|
|
|
element.accordion( "option", "active", -2 );
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.equal( element.accordion( "option", "active" ), 1 );
|
|
|
|
state( assert, element, 0, 1, 0 );
|
2012-10-24 15:11:47 +00:00
|
|
|
|
|
|
|
element.accordion( "option", "active", -10 );
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.equal( element.accordion( "option", "active" ), 1 );
|
|
|
|
state( assert, element, 0, 1, 0 );
|
2012-10-24 15:11:47 +00:00
|
|
|
|
|
|
|
element.accordion( "option", "active", -3 );
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.equal( element.accordion( "option", "active" ), 0 );
|
|
|
|
state( assert, element, 1, 0, 0 );
|
2015-08-21 04:12:07 +00:00
|
|
|
} );
|
2011-01-25 00:20:09 +00:00
|
|
|
|
2016-04-03 14:37:27 +00:00
|
|
|
QUnit.test( "{ animate: false }", function( assert ) {
|
|
|
|
assert.expect( 3 );
|
2015-08-21 04:12:07 +00:00
|
|
|
var element = $( "#list1" ).accordion( {
|
2012-03-27 22:05:51 +00:00
|
|
|
animate: false
|
2015-08-21 04:12:07 +00:00
|
|
|
} ),
|
2012-04-19 14:50:09 +00:00
|
|
|
panels = element.find( ".ui-accordion-content" ),
|
2012-03-27 22:05:51 +00:00
|
|
|
animate = $.fn.animate;
|
|
|
|
$.fn.animate = function() {
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.ok( false, ".animate() called" );
|
2012-03-27 22:05:51 +00:00
|
|
|
};
|
|
|
|
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
|
2012-03-27 22:05:51 +00:00
|
|
|
element.accordion( "option", "active", 1 );
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
|
|
|
|
assert.ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
|
2012-03-27 22:05:51 +00:00
|
|
|
$.fn.animate = animate;
|
2015-08-21 04:12:07 +00:00
|
|
|
} );
|
2012-03-27 22:05:51 +00:00
|
|
|
|
2016-04-03 14:37:27 +00:00
|
|
|
QUnit.test( "{ animate: Number }", function( assert ) {
|
|
|
|
var ready = assert.async();
|
|
|
|
assert.expect( 7 );
|
2015-08-21 04:12:07 +00:00
|
|
|
var element = $( "#list1" ).accordion( {
|
2012-03-27 22:05:51 +00:00
|
|
|
animate: 100
|
2015-08-21 04:12:07 +00:00
|
|
|
} ),
|
2012-04-19 14:50:09 +00:00
|
|
|
panels = element.find( ".ui-accordion-content" ),
|
2012-03-27 22:05:51 +00:00
|
|
|
animate = $.fn.animate;
|
2015-08-21 04:12:07 +00:00
|
|
|
|
|
|
|
// Called twice (both panels)
|
2012-10-01 20:52:54 +00:00
|
|
|
$.fn.animate = function( props, options ) {
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.equal( options.duration, 100, "correct duration" );
|
|
|
|
assert.equal( options.easing, undefined, "default easing" );
|
2012-03-27 22:05:51 +00:00
|
|
|
animate.apply( this, arguments );
|
|
|
|
};
|
|
|
|
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
|
2012-03-27 22:05:51 +00:00
|
|
|
element.accordion( "option", "active", 1 );
|
2015-08-21 04:12:07 +00:00
|
|
|
panels.promise().done( function() {
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
|
|
|
|
assert.ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
|
2012-03-27 22:05:51 +00:00
|
|
|
$.fn.animate = animate;
|
2016-04-03 14:37:27 +00:00
|
|
|
ready();
|
2015-08-21 04:12:07 +00:00
|
|
|
} );
|
|
|
|
} );
|
2012-03-27 22:05:51 +00:00
|
|
|
|
2016-04-03 14:37:27 +00:00
|
|
|
QUnit.test( "{ animate: String }", function( assert ) {
|
|
|
|
var ready = assert.async();
|
|
|
|
assert.expect( 7 );
|
2015-08-21 04:12:07 +00:00
|
|
|
var element = $( "#list1" ).accordion( {
|
2012-04-19 14:50:09 +00:00
|
|
|
animate: "linear"
|
2015-08-21 04:12:07 +00:00
|
|
|
} ),
|
2012-04-19 14:50:09 +00:00
|
|
|
panels = element.find( ".ui-accordion-content" ),
|
|
|
|
animate = $.fn.animate;
|
2015-08-21 04:12:07 +00:00
|
|
|
|
|
|
|
// Called twice (both panels)
|
2012-10-01 20:52:54 +00:00
|
|
|
$.fn.animate = function( props, options ) {
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.equal( options.duration, undefined, "default duration" );
|
|
|
|
assert.equal( options.easing, "linear", "correct easing" );
|
2012-03-27 22:05:51 +00:00
|
|
|
animate.apply( this, arguments );
|
|
|
|
};
|
|
|
|
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
|
2012-03-27 22:05:51 +00:00
|
|
|
element.accordion( "option", "active", 1 );
|
2015-08-21 04:12:07 +00:00
|
|
|
panels.promise().done( function() {
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
|
|
|
|
assert.ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
|
2012-03-27 22:05:51 +00:00
|
|
|
$.fn.animate = animate;
|
2016-04-03 14:37:27 +00:00
|
|
|
ready();
|
2015-08-21 04:12:07 +00:00
|
|
|
} );
|
|
|
|
} );
|
2012-03-27 22:05:51 +00:00
|
|
|
|
2016-04-03 14:37:27 +00:00
|
|
|
QUnit.test( "{ animate: {} }", function( assert ) {
|
|
|
|
var ready = assert.async();
|
|
|
|
assert.expect( 7 );
|
2015-08-21 04:12:07 +00:00
|
|
|
var element = $( "#list1" ).accordion( {
|
2012-04-19 14:50:09 +00:00
|
|
|
animate: {}
|
2015-08-21 04:12:07 +00:00
|
|
|
} ),
|
2012-04-19 14:50:09 +00:00
|
|
|
panels = element.find( ".ui-accordion-content" ),
|
|
|
|
animate = $.fn.animate;
|
2015-08-21 04:12:07 +00:00
|
|
|
|
|
|
|
// Called twice (both panels)
|
2012-10-01 20:52:54 +00:00
|
|
|
$.fn.animate = function( props, options ) {
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.equal( options.duration, undefined, "default duration" );
|
|
|
|
assert.equal( options.easing, undefined, "default easing" );
|
2012-03-27 22:05:51 +00:00
|
|
|
animate.apply( this, arguments );
|
|
|
|
};
|
|
|
|
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
|
2012-03-27 22:05:51 +00:00
|
|
|
element.accordion( "option", "active", 1 );
|
2015-08-21 04:12:07 +00:00
|
|
|
panels.promise().done( function() {
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
|
|
|
|
assert.ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
|
2012-03-27 22:05:51 +00:00
|
|
|
$.fn.animate = animate;
|
2016-04-03 14:37:27 +00:00
|
|
|
ready();
|
2015-08-21 04:12:07 +00:00
|
|
|
} );
|
|
|
|
} );
|
2012-03-27 22:05:51 +00:00
|
|
|
|
2016-04-03 14:37:27 +00:00
|
|
|
QUnit.test( "{ animate: { duration, easing } }", function( assert ) {
|
|
|
|
var ready = assert.async();
|
|
|
|
assert.expect( 7 );
|
2015-08-21 04:12:07 +00:00
|
|
|
var element = $( "#list1" ).accordion( {
|
2012-04-19 14:50:09 +00:00
|
|
|
animate: { duration: 100, easing: "linear" }
|
2015-08-21 04:12:07 +00:00
|
|
|
} ),
|
2012-04-19 14:50:09 +00:00
|
|
|
panels = element.find( ".ui-accordion-content" ),
|
|
|
|
animate = $.fn.animate;
|
2015-08-21 04:12:07 +00:00
|
|
|
|
|
|
|
// Called twice (both panels)
|
2012-10-01 20:52:54 +00:00
|
|
|
$.fn.animate = function( props, options ) {
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.equal( options.duration, 100, "correct duration" );
|
|
|
|
assert.equal( options.easing, "linear", "correct easing" );
|
2012-03-27 22:05:51 +00:00
|
|
|
animate.apply( this, arguments );
|
|
|
|
};
|
|
|
|
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
|
2012-03-27 22:05:51 +00:00
|
|
|
element.accordion( "option", "active", 1 );
|
2015-08-21 04:12:07 +00:00
|
|
|
panels.promise().done( function() {
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
|
|
|
|
assert.ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
|
2012-03-27 22:05:51 +00:00
|
|
|
$.fn.animate = animate;
|
2016-04-03 14:37:27 +00:00
|
|
|
ready();
|
2015-08-21 04:12:07 +00:00
|
|
|
} );
|
|
|
|
} );
|
2012-03-27 22:05:51 +00:00
|
|
|
|
2016-04-03 14:37:27 +00:00
|
|
|
QUnit.test( "{ animate: { duration, easing } }, animate down", function( assert ) {
|
|
|
|
var ready = assert.async();
|
|
|
|
assert.expect( 7 );
|
2015-08-21 04:12:07 +00:00
|
|
|
var element = $( "#list1" ).accordion( {
|
2012-04-19 14:50:09 +00:00
|
|
|
active: 1,
|
|
|
|
animate: { duration: 100, easing: "linear" }
|
2015-08-21 04:12:07 +00:00
|
|
|
} ),
|
2012-04-19 14:50:09 +00:00
|
|
|
panels = element.find( ".ui-accordion-content" ),
|
|
|
|
animate = $.fn.animate;
|
2015-08-21 04:12:07 +00:00
|
|
|
|
|
|
|
// Called twice (both panels)
|
2012-10-01 20:52:54 +00:00
|
|
|
$.fn.animate = function( props, options ) {
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.equal( options.duration, 100, "correct duration" );
|
|
|
|
assert.equal( options.easing, "linear", "correct easing" );
|
2012-03-27 22:05:51 +00:00
|
|
|
animate.apply( this, arguments );
|
|
|
|
};
|
|
|
|
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.ok( panels.eq( 1 ).is( ":visible" ), "first panel visible" );
|
2012-03-27 22:05:51 +00:00
|
|
|
element.accordion( "option", "active", 0 );
|
2015-08-21 04:12:07 +00:00
|
|
|
panels.promise().done( function() {
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.ok( panels.eq( 1 ).is( ":hidden" ), "first panel hidden" );
|
|
|
|
assert.ok( panels.eq( 0 ).is( ":visible" ), "second panel visible" );
|
2012-03-27 22:05:51 +00:00
|
|
|
$.fn.animate = animate;
|
2016-04-03 14:37:27 +00:00
|
|
|
ready();
|
2015-08-21 04:12:07 +00:00
|
|
|
} );
|
|
|
|
} );
|
2012-03-27 22:05:51 +00:00
|
|
|
|
2016-04-03 14:37:27 +00:00
|
|
|
QUnit.test( "{ animate: { duration, easing, down } }, animate down", function( assert ) {
|
|
|
|
var ready = assert.async();
|
|
|
|
assert.expect( 7 );
|
2015-08-21 04:12:07 +00:00
|
|
|
var element = $( "#list1" ).accordion( {
|
2012-04-19 14:50:09 +00:00
|
|
|
active: 1,
|
|
|
|
animate: {
|
|
|
|
duration: 100,
|
|
|
|
easing: "linear",
|
|
|
|
down: {
|
|
|
|
easing: "swing"
|
|
|
|
}
|
2012-03-27 22:05:51 +00:00
|
|
|
}
|
2015-08-21 04:12:07 +00:00
|
|
|
} ),
|
2012-04-19 14:50:09 +00:00
|
|
|
panels = element.find( ".ui-accordion-content" ),
|
|
|
|
animate = $.fn.animate;
|
2015-08-21 04:12:07 +00:00
|
|
|
|
|
|
|
// Called twice (both panels)
|
2012-10-01 20:52:54 +00:00
|
|
|
$.fn.animate = function( props, options ) {
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.equal( options.duration, 100, "correct duration" );
|
|
|
|
assert.equal( options.easing, "swing", "correct easing" );
|
2012-03-27 22:05:51 +00:00
|
|
|
animate.apply( this, arguments );
|
|
|
|
};
|
|
|
|
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.ok( panels.eq( 1 ).is( ":visible" ), "first panel visible" );
|
2012-03-27 22:05:51 +00:00
|
|
|
element.accordion( "option", "active", 0 );
|
2015-08-21 04:12:07 +00:00
|
|
|
panels.promise().done( function() {
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.ok( panels.eq( 1 ).is( ":hidden" ), "first panel hidden" );
|
|
|
|
assert.ok( panels.eq( 0 ).is( ":visible" ), "second panel visible" );
|
2012-03-27 22:05:51 +00:00
|
|
|
$.fn.animate = animate;
|
2016-04-03 14:37:27 +00:00
|
|
|
ready();
|
2015-08-21 04:12:07 +00:00
|
|
|
} );
|
|
|
|
} );
|
2010-12-15 04:48:36 +00:00
|
|
|
|
2016-04-03 14:37:27 +00:00
|
|
|
QUnit.test( "{ collapsible: false }", function( assert ) {
|
|
|
|
assert.expect( 4 );
|
2015-08-21 04:12:07 +00:00
|
|
|
var element = $( "#list1" ).accordion( {
|
2011-01-25 00:20:09 +00:00
|
|
|
active: 1
|
2015-08-21 04:12:07 +00:00
|
|
|
} );
|
2011-04-15 15:29:26 +00:00
|
|
|
element.accordion( "option", "active", false );
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.equal( element.accordion( "option", "active" ), 1 );
|
|
|
|
state( assert, element, 0, 1, 0 );
|
2011-01-25 00:20:09 +00:00
|
|
|
|
2015-05-14 01:52:09 +00:00
|
|
|
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "click" );
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.equal( element.accordion( "option", "active" ), 1 );
|
|
|
|
state( assert, element, 0, 1, 0 );
|
2015-08-21 04:12:07 +00:00
|
|
|
} );
|
2009-02-03 08:23:48 +00:00
|
|
|
|
2016-04-03 14:37:27 +00:00
|
|
|
QUnit.test( "{ collapsible: true }", function( assert ) {
|
|
|
|
assert.expect( 6 );
|
2015-08-21 04:12:07 +00:00
|
|
|
var element = $( "#list1" ).accordion( {
|
2009-08-11 00:57:50 +00:00
|
|
|
active: 1,
|
|
|
|
collapsible: true
|
2015-08-21 04:12:07 +00:00
|
|
|
} );
|
2011-01-25 00:20:09 +00:00
|
|
|
|
2011-04-15 15:29:26 +00:00
|
|
|
element.accordion( "option", "active", false );
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.equal( element.accordion( "option", "active" ), false );
|
|
|
|
state( assert, element, 0, 0, 0 );
|
2011-01-25 00:20:09 +00:00
|
|
|
|
2011-04-15 15:29:26 +00:00
|
|
|
element.accordion( "option", "active", 1 );
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.equal( element.accordion( "option", "active" ), 1 );
|
|
|
|
state( assert, element, 0, 1, 0 );
|
2011-01-25 00:20:09 +00:00
|
|
|
|
2015-05-14 01:52:09 +00:00
|
|
|
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "click" );
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.equal( element.accordion( "option", "active" ), false );
|
|
|
|
state( assert, element, 0, 0, 0 );
|
2015-08-21 04:12:07 +00:00
|
|
|
} );
|
2009-02-03 08:23:48 +00:00
|
|
|
|
2016-04-03 14:37:27 +00:00
|
|
|
QUnit.test( "{ event: null }", function( assert ) {
|
|
|
|
assert.expect( 5 );
|
2015-08-21 04:12:07 +00:00
|
|
|
var element = $( "#list1" ).accordion( {
|
2011-02-21 15:07:42 +00:00
|
|
|
event: null
|
2015-08-21 04:12:07 +00:00
|
|
|
} );
|
2016-04-03 14:37:27 +00:00
|
|
|
state( assert, element, 1, 0, 0 );
|
2011-02-21 15:07:42 +00:00
|
|
|
|
2011-04-15 15:29:26 +00:00
|
|
|
element.accordion( "option", "active", 1 );
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.equal( element.accordion( "option", "active" ), 1 );
|
|
|
|
state( assert, element, 0, 1, 0 );
|
2011-02-21 15:07:42 +00:00
|
|
|
|
2015-08-21 04:12:07 +00:00
|
|
|
// Ensure default click handler isn't bound
|
2015-05-14 01:52:09 +00:00
|
|
|
element.find( ".ui-accordion-header" ).eq( 2 ).trigger( "click" );
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.equal( element.accordion( "option", "active" ), 1 );
|
|
|
|
state( assert, element, 0, 1, 0 );
|
2015-08-21 04:12:07 +00:00
|
|
|
} );
|
2011-02-21 15:07:42 +00:00
|
|
|
|
2016-04-03 14:37:27 +00:00
|
|
|
QUnit.test( "{ event: custom }", function( assert ) {
|
|
|
|
assert.expect( 11 );
|
2015-08-21 04:12:07 +00:00
|
|
|
var element = $( "#list1" ).accordion( {
|
2011-02-21 15:07:42 +00:00
|
|
|
event: "custom1 custom2"
|
2015-08-21 04:12:07 +00:00
|
|
|
} );
|
2016-04-03 14:37:27 +00:00
|
|
|
state( assert, element, 1, 0, 0 );
|
2011-02-21 15:07:42 +00:00
|
|
|
|
2011-04-15 15:29:26 +00:00
|
|
|
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom1" );
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.equal( element.accordion( "option", "active" ), 1 );
|
|
|
|
state( assert, element, 0, 1, 0 );
|
2011-02-21 15:07:42 +00:00
|
|
|
|
2015-08-21 04:12:07 +00:00
|
|
|
// Ensure default click handler isn't bound
|
2011-04-15 15:29:26 +00:00
|
|
|
element.find( ".ui-accordion-header" ).eq( 2 ).trigger( "click" );
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.equal( element.accordion( "option", "active" ), 1 );
|
|
|
|
state( assert, element, 0, 1, 0 );
|
2011-02-21 15:07:42 +00:00
|
|
|
|
2011-04-15 15:29:26 +00:00
|
|
|
element.find( ".ui-accordion-header" ).eq( 2 ).trigger( "custom2" );
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.equal( element.accordion( "option", "active" ), 2 );
|
|
|
|
state( assert, element, 0, 0, 1 );
|
2011-02-21 15:07:42 +00:00
|
|
|
|
2011-04-15 15:29:26 +00:00
|
|
|
element.accordion( "option", "event", "custom3" );
|
2011-02-21 15:07:42 +00:00
|
|
|
|
2015-08-21 04:12:07 +00:00
|
|
|
// Ensure old event handlers are unbound
|
2011-04-15 15:29:26 +00:00
|
|
|
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom1" );
|
2012-03-07 18:17:09 +00:00
|
|
|
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom2" );
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.equal( element.accordion( "option", "active" ), 2 );
|
|
|
|
state( assert, element, 0, 0, 1 );
|
2011-02-21 15:07:42 +00:00
|
|
|
|
2011-04-15 15:29:26 +00:00
|
|
|
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom3" );
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.equal( element.accordion( "option", "active" ), 1 );
|
|
|
|
state( assert, element, 0, 1, 0 );
|
2015-08-21 04:12:07 +00:00
|
|
|
} );
|
2011-01-25 00:20:09 +00:00
|
|
|
|
2016-04-03 14:37:27 +00:00
|
|
|
QUnit.test( "{ header: default }", function( assert ) {
|
|
|
|
assert.expect( 2 );
|
2015-08-21 04:12:07 +00:00
|
|
|
|
2020-01-22 15:44:34 +00:00
|
|
|
// Default: elem.find( "> li > :first-child" ).add( elem.find( "> :not(li)" ).even() )
|
|
|
|
// elem.find( "> :not(li)" ).even()
|
2016-04-03 14:37:27 +00:00
|
|
|
state( assert, $( "#list1" ).accordion(), 1, 0, 0 );
|
2015-08-21 04:12:07 +00:00
|
|
|
|
2011-01-25 00:20:09 +00:00
|
|
|
// > li > :first-child
|
2016-04-03 14:37:27 +00:00
|
|
|
state( assert, $( "#navigation" ).accordion(), 1, 0, 0 );
|
2015-08-21 04:12:07 +00:00
|
|
|
} );
|
2010-12-15 04:48:36 +00:00
|
|
|
|
2020-01-22 15:44:34 +00:00
|
|
|
QUnit.test( "{ header: customString }", function( assert ) {
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.expect( 6 );
|
2015-08-21 04:12:07 +00:00
|
|
|
var element = $( "#navigationWrapper" ).accordion( {
|
2011-02-03 15:11:00 +00:00
|
|
|
header: "h2"
|
2015-08-21 04:12:07 +00:00
|
|
|
} );
|
|
|
|
element.find( "h2" ).each( function() {
|
2015-01-30 14:53:26 +00:00
|
|
|
assert.hasClasses( this, "ui-accordion-header" );
|
2015-08-21 04:12:07 +00:00
|
|
|
} );
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.equal( element.find( ".ui-accordion-header" ).length, 3 );
|
|
|
|
state( assert, element, 1, 0, 0 );
|
2011-04-15 15:29:26 +00:00
|
|
|
element.accordion( "option", "active", 2 );
|
2016-04-03 14:37:27 +00:00
|
|
|
state( assert, element, 0, 0, 1 );
|
2020-01-22 15:44:34 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
QUnit.test( "{ header: customFunction }", function( assert ) {
|
|
|
|
assert.expect( 6 );
|
|
|
|
var element = $( "#navigationWrapper" ).accordion( {
|
|
|
|
header: function( elem ) {
|
|
|
|
return elem.find( "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 );
|
2015-08-21 04:12:07 +00:00
|
|
|
} );
|
2011-02-03 15:11:00 +00:00
|
|
|
|
2016-04-03 14:37:27 +00:00
|
|
|
QUnit.test( "{ heightStyle: 'auto' }", function( assert ) {
|
|
|
|
assert.expect( 3 );
|
2015-08-21 04:12:07 +00:00
|
|
|
var element = $( "#navigation" ).accordion( { heightStyle: "auto" } );
|
2016-04-03 14:37:27 +00:00
|
|
|
equalHeight( assert, element, 105 );
|
2015-08-21 04:12:07 +00:00
|
|
|
} );
|
2009-02-03 08:23:48 +00:00
|
|
|
|
2016-04-03 14:37:27 +00:00
|
|
|
QUnit.test( "{ heightStyle: 'content' }", function( assert ) {
|
|
|
|
assert.expect( 3 );
|
2015-08-21 04:12:07 +00:00
|
|
|
var element = $( "#navigation" ).accordion( { heightStyle: "content" } ),
|
|
|
|
sizes = element.find( ".ui-accordion-content" ).map( function() {
|
2012-04-19 14:50:09 +00:00
|
|
|
return $( this ).height();
|
2015-08-21 04:12:07 +00:00
|
|
|
} ).get();
|
2016-04-03 14:37:27 +00:00
|
|
|
assert.equal( sizes[ 0 ], 75 );
|
|
|
|
assert.equal( sizes[ 1 ], 105 );
|
|
|
|
assert.equal( sizes[ 2 ], 45 );
|
2015-08-21 04:12:07 +00:00
|
|
|
} );
|
2009-05-11 11:43:48 +00:00
|
|
|
|
2016-04-03 14:37:27 +00:00
|
|
|
QUnit.test( "{ heightStyle: 'fill' }", function( assert ) {
|
|
|
|
assert.expect( 3 );
|
2011-01-25 00:20:09 +00:00
|
|
|
$( "#navigationWrapper" ).height( 500 );
|
2015-08-21 04:12:07 +00:00
|
|
|
var element = $( "#navigation" ).accordion( { heightStyle: "fill" } );
|
2016-04-03 14:37:27 +00:00
|
|
|
equalHeight( assert, element, 455 );
|
2015-08-21 04:12:07 +00:00
|
|
|
} );
|
2011-01-25 00:20:09 +00:00
|
|
|
|
2016-04-03 14:37:27 +00:00
|
|
|
QUnit.test( "{ heightStyle: 'fill' } with sibling", function( assert ) {
|
|
|
|
assert.expect( 3 );
|
2011-01-25 01:35:58 +00:00
|
|
|
$( "#navigationWrapper" ).height( 500 );
|
|
|
|
$( "<p>Lorem Ipsum</p>" )
|
2015-08-21 04:12:07 +00:00
|
|
|
.css( {
|
2011-01-25 01:35:58 +00:00
|
|
|
height: 50,
|
|
|
|
marginTop: 20,
|
|
|
|
marginBottom: 30
|
2015-08-21 04:12:07 +00:00
|
|
|
} )
|
2011-01-25 01:35:58 +00:00
|
|
|
.prependTo( "#navigationWrapper" );
|
2015-08-21 04:12:07 +00:00
|
|
|
var element = $( "#navigation" ).accordion( { heightStyle: "fill" } );
|
2016-04-03 14:37:27 +00:00
|
|
|
equalHeight( assert, element, 355 );
|
2015-08-21 04:12:07 +00:00
|
|
|
} );
|
2011-01-25 01:35:58 +00:00
|
|
|
|
2016-04-03 14:37:27 +00:00
|
|
|
QUnit.test( "{ heightStyle: 'fill' } with multiple siblings", function( assert ) {
|
|
|
|
assert.expect( 3 );
|
2011-01-25 01:35:58 +00:00
|
|
|
$( "#navigationWrapper" ).height( 500 );
|
|
|
|
$( "<p>Lorem Ipsum</p>" )
|
2015-08-21 04:12:07 +00:00
|
|
|
.css( {
|
2011-01-25 01:35:58 +00:00
|
|
|
height: 50,
|
|
|
|
marginTop: 20,
|
|
|
|
marginBottom: 30
|
2015-08-21 04:12:07 +00:00
|
|
|
} )
|
2011-01-25 01:35:58 +00:00
|
|
|
.prependTo( "#navigationWrapper" );
|
|
|
|
$( "<p>Lorem Ipsum</p>" )
|
2015-08-21 04:12:07 +00:00
|
|
|
.css( {
|
2011-01-25 01:35:58 +00:00
|
|
|
height: 50,
|
|
|
|
marginTop: 20,
|
|
|
|
marginBottom: 30,
|
|
|
|
position: "absolute"
|
2015-08-21 04:12:07 +00:00
|
|
|
} )
|
2011-01-25 01:35:58 +00:00
|
|
|
.prependTo( "#navigationWrapper" );
|
|
|
|
$( "<p>Lorem Ipsum</p>" )
|
2015-08-21 04:12:07 +00:00
|
|
|
.css( {
|
2011-01-25 01:35:58 +00:00
|
|
|
height: 25,
|
|
|
|
marginTop: 10,
|
|
|
|
marginBottom: 15
|
2015-08-21 04:12:07 +00:00
|
|
|
} )
|
2011-01-25 01:35:58 +00:00
|
|
|
.prependTo( "#navigationWrapper" );
|
2015-08-21 04:12:07 +00:00
|
|
|
var element = $( "#navigation" ).accordion( { heightStyle: "fill" } );
|
2016-04-03 14:37:27 +00:00
|
|
|
equalHeight( assert, element, 305 );
|
2015-08-21 04:12:07 +00:00
|
|
|
} );
|
2011-01-11 20:38:47 +00:00
|
|
|
|
2016-04-03 14:37:27 +00:00
|
|
|
QUnit.test( "{ icons: false }", function( assert ) {
|
|
|
|
assert.expect( 8 );
|
2011-04-15 15:29:26 +00:00
|
|
|
var element = $( "#list1" );
|
2011-01-25 00:20:09 +00:00
|
|
|
function icons( on ) {
|
2016-04-03 14:37:27 +00:00
|
|
|
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 );
|
2011-01-25 00:20:09 +00:00
|
|
|
}
|
2011-04-15 15:29:26 +00:00
|
|
|
element.accordion();
|
2011-01-25 00:20:09 +00:00
|
|
|
icons( true );
|
2015-08-21 04:12:07 +00:00
|
|
|
element.accordion( "destroy" ).accordion( {
|
2011-01-25 00:20:09 +00:00
|
|
|
icons: false
|
2015-08-21 04:12:07 +00:00
|
|
|
} );
|
2011-01-25 00:20:09 +00:00
|
|
|
icons( false );
|
2011-04-15 15:29:26 +00:00
|
|
|
element.accordion( "option", "icons", { header: "foo", activeHeader: "bar" } );
|
2011-01-25 00:20:09 +00:00
|
|
|
icons( true );
|
2011-04-15 15:29:26 +00:00
|
|
|
element.accordion( "option", "icons", false );
|
2011-01-25 00:20:09 +00:00
|
|
|
icons( false );
|
2015-08-21 04:12:07 +00:00
|
|
|
} );
|
2009-02-03 08:23:48 +00:00
|
|
|
|
2016-04-03 14:37:27 +00:00
|
|
|
QUnit.test( "{ icons: hash }", function( assert ) {
|
|
|
|
assert.expect( 3 );
|
2015-08-21 04:12:07 +00:00
|
|
|
var element = $( "#list1" ).accordion( {
|
2011-01-25 00:20:09 +00:00
|
|
|
icons: { activeHeader: "a1", header: "h1" }
|
2015-08-21 04:12:07 +00:00
|
|
|
} );
|
2015-01-30 14:53:26 +00:00
|
|
|
assert.hasClasses( element.find( ".ui-accordion-header.ui-state-active span.ui-icon" ), "a1" );
|
2011-04-15 15:29:26 +00:00
|
|
|
element.accordion( "option", "icons", { activeHeader: "a2", header: "h2" } );
|
2015-08-21 04:12:07 +00:00
|
|
|
assert.lacksClasses( element.find( ".ui-accordion-header.ui-state-active span.ui-icon" ), "a1" );
|
2015-01-30 14:53:26 +00:00
|
|
|
assert.hasClasses( element.find( ".ui-accordion-header.ui-state-active span.ui-icon" ), "a2" );
|
2015-08-21 04:12:07 +00:00
|
|
|
} );
|
2009-02-02 14:36:08 +00:00
|
|
|
|
2015-04-03 19:24:09 +00:00
|
|
|
} );
|