aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2011-02-21 16:07:42 +0100
committerScott González <scott.gonzalez@gmail.com>2011-02-21 16:07:59 +0100
commitf70f01af9ea1d1d191b77fab6dadbbe421be43a8 (patch)
treee866789872707043674fea78fe5c944e2e3491ec /tests/unit
parent84a4a4442d25631bd00b50d48ff2d57a6089f6d3 (diff)
downloadjquery-ui-f70f01af9ea1d1d191b77fab6dadbbe421be43a8.tar.gz
jquery-ui-f70f01af9ea1d1d191b77fab6dadbbe421be43a8.zip
Accordion: Handle changing the event option. Fixes #6740 - Dynamically changing accordion's event handler doesn't actually change the behaviour.
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/accordion/accordion_options.js47
1 files changed, 46 insertions, 1 deletions
diff --git a/tests/unit/accordion/accordion_options.js b/tests/unit/accordion/accordion_options.js
index f27431a50..42cbb495c 100644
--- a/tests/unit/accordion/accordion_options.js
+++ b/tests/unit/accordion/accordion_options.js
@@ -105,7 +105,52 @@ test( "{ collapsible: true }", function() {
state( ac, 0, 0, 0 );
});
-// TODO: add event tests
+test( "{ event: null }", function() {
+ var ac = $( "#list1" ).accordion({
+ event: null
+ });
+ state( ac, 1, 0, 0 );
+
+ ac.accordion( "option", "active", 1 );
+ equal( ac.accordion( "option", "active" ), 1 );
+ state( ac, 0, 1, 0 );
+
+ // ensure default click handler isn't bound
+ ac.find( ".ui-accordion-header" ).eq( 2 ).click();
+ equal( ac.accordion( "option", "active" ), 1 );
+ state( ac, 0, 1, 0 );
+});
+
+test( "{ event: custom }", function() {
+ var ac = $( "#list1" ).accordion({
+ event: "custom1 custom2"
+ });
+ state( ac, 1, 0, 0 );
+
+ ac.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom1" );
+ equal( ac.accordion( "option", "active" ), 1 );
+ state( ac, 0, 1, 0 );
+
+ // ensure default click handler isn't bound
+ ac.find( ".ui-accordion-header" ).eq( 2 ).trigger( "click" );
+ equal( ac.accordion( "option", "active" ), 1 );
+ state( ac, 0, 1, 0 );
+
+ ac.find( ".ui-accordion-header" ).eq( 2 ).trigger( "custom2" );
+ equal( ac.accordion( "option", "active" ), 2 );
+ state( ac, 0, 0, 1 );
+
+ ac.accordion( "option", "event", "custom3" );
+
+ // ensure old event handlers are unbound
+ ac.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom1" );
+ equal( ac.accordion( "option", "active" ), 2 );
+ state( ac, 0, 0, 1 );
+
+ ac.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom3" );
+ equal( ac.accordion( "option", "active" ), 1 );
+ state( ac, 0, 1, 0 );
+});
test( "{ header: default }", function() {
// default: > li > :first-child,> :not(li):even