@@ -9,7 +9,7 @@ test('init', function() {
99 expect ( 9 ) ;
1010
1111 el = $ ( '#tabs1' ) . tabs ( ) ;
12-
12+
1313 ok ( true , '.tabs() called on element' ) ;
1414 ok ( el . is ( '.ui-tabs.ui-widget.ui-widget-content.ui-corner-all' ) , 'attach classes to container' ) ;
1515 ok ( $ ( 'ul' , el ) . is ( '.ui-tabs-nav.ui-helper-reset.ui-helper-clearfix.ui-widget-header.ui-corner-all' ) , 'attach classes to list' ) ;
@@ -23,68 +23,84 @@ test('init', function() {
2323
2424test ( 'destroy' , function ( ) {
2525 expect ( 6 ) ;
26-
26+
2727 el = $ ( '#tabs1' ) . tabs ( { collapsible : true } ) ;
2828 $ ( 'li:eq(2)' , el ) . simulate ( 'mouseover' ) . find ( 'a' ) . focus ( ) ;
2929 el . tabs ( 'destroy' ) ;
30-
30+
3131 ok ( el . is ( ':not(.ui-tabs, .ui-widget, .ui-widget-content, .ui-corner-all, .ui-tabs-collapsible)' ) , 'remove classes from container' ) ;
3232 ok ( $ ( 'ul' , el ) . is ( ':not(.ui-tabs-nav, .ui-helper-reset, .ui-helper-clearfix, .ui-widget-header, .ui-corner-all)' ) , 'remove classes from list' ) ;
3333 ok ( $ ( 'div:eq(1)' , el ) . is ( ':not(.ui-tabs-panel, .ui-widget-content, .ui-corner-bottom, .ui-tabs-hide)' ) , 'remove classes to panel' ) ;
34- ok ( $ ( 'li:eq(0)' , el ) . is ( ':not(.ui-tabs-selected, .ui-state-active, .ui-corner-top)' ) , 'remove classes from active li' ) ;
34+ ok ( $ ( 'li:eq(0)' , el ) . is ( ':not(.ui-tabs-selected, .ui-state-active, .ui-corner-top)' ) , 'remove classes from active li' ) ;
3535 ok ( $ ( 'li:eq(1)' , el ) . is ( ':not(.ui-state-default, .ui-corner-top)' ) , 'remove classes from inactive li' ) ;
3636 ok ( $ ( 'li:eq(2)' , el ) . is ( ':not(.ui-state-hover, .ui-state-focus)' ) , 'remove classes from mouseovered or focused li' ) ;
3737} ) ;
3838
3939test ( 'enable' , function ( ) {
40- ok ( false , "missing test - untested code is broken code." ) ;
40+ expect ( 2 ) ;
41+
42+ el = $ ( '#tabs1' ) . tabs ( { disabled : [ 0 , 1 ] } ) ;
43+ el . tabs ( "enable" , 1 ) ;
44+ ok ( $ ( 'li:eq(1)' , el ) . is ( ':not(.ui-state-disabled)' ) , 'remove class from li' ) ;
45+ same ( el . tabs ( 'option' , 'disabled' ) , [ ] , 'update property' ) ;
4146} ) ;
4247
4348test ( 'disable' , function ( ) {
44- ok ( false , "missing test - untested code is broken code." ) ;
49+ expect ( 4 ) ;
50+
51+ // normal
52+ el = $ ( '#tabs1' ) . tabs ( ) ;
53+ el . tabs ( 'disable' , 1 ) ;
54+ ok ( $ ( 'li:eq(1)' , el ) . is ( '.ui-state-disabled' ) , 'add class to li' ) ;
55+ same ( el . tabs ( 'option' , 'disabled' ) , [ 1 ] , 'update disabled property' ) ;
56+
57+ // attempt to disable selected has no effect
58+ el . tabs ( 'disable' , 0 ) ;
59+ ok ( $ ( 'li:eq(0)' , el ) . is ( ':not(.ui-state-disabled)' ) , 'not add class to li' ) ;
60+ same ( el . tabs ( 'option' , 'disabled' ) , [ 1 ] , 'not update property' ) ;
4561} ) ;
4662
4763test ( 'add' , function ( ) {
4864 expect ( 4 ) ;
49-
65+
5066 el = $ ( '#tabs1' ) . tabs ( ) ;
51- el . tabs ( 'add' , " #new" , 'New' ) ;
67+ el . tabs ( 'add' , ' #new' , 'New' ) ;
5268
5369 var added = $ ( 'li:last' , el ) . simulate ( 'mouseover' ) ;
5470 ok ( added . is ( '.ui-state-hover' ) , 'should add mouseover handler to added tab' ) ;
5571 added . simulate ( 'mouseout' ) ;
5672 var other = $ ( 'li:first' , el ) . simulate ( 'mouseover' ) ;
5773 ok ( other . is ( '.ui-state-hover' ) , 'should not remove mouseover handler from existing tab' ) ;
5874 other . simulate ( 'mouseout' ) ;
59-
75+
6076 equals ( $ ( 'a' , added ) . attr ( 'href' ) , '#new' , 'should not expand href to full url of current page' ) ;
61-
77+
6278 ok ( false , "missing test - untested code is broken code." ) ;
6379} ) ;
6480
6581test ( 'remove' , function ( ) {
6682 expect ( 4 ) ;
6783
6884 el = $ ( '#tabs1' ) . tabs ( ) ;
69-
85+
7086 el . tabs ( 'remove' , 0 ) ;
7187 equals ( el . tabs ( 'length' ) , 2 , 'remove tab' ) ;
7288 equals ( $ ( 'li a[href$="fragment-1"]' , el ) . length , 0 , 'remove associated list item' ) ;
7389 equals ( $ ( '#fragment-1' ) . length , 0 , 'remove associated panel' ) ;
74-
90+
7591 // TODO delete tab -> focus tab to right
7692 // TODO delete last tab -> focus tab to left
77-
93+
7894 el . tabs ( 'select' , 1 ) ;
7995 el . tabs ( 'remove' , 1 ) ;
80- equals ( el . tabs ( 'option' , 'selected' ) , 0 , 'update selected property' ) ;
96+ equals ( el . tabs ( 'option' , 'selected' ) , 0 , 'update selected property' ) ;
8197} ) ;
8298
8399test ( 'select' , function ( ) {
84100 expect ( 9 ) ;
85-
101+
86102 el = $ ( '#tabs1' ) . tabs ( ) ;
87-
103+
88104 el . tabs ( 'select' , 1 ) ;
89105 equals ( el . tabs ( 'option' , 'selected' ) , 1 , 'should select tab' ) ;
90106
@@ -97,11 +113,11 @@ test('select', function() {
97113 el . tabs ( { collapsible : true } ) ;
98114 el . tabs ( 'select' , - 1 ) ;
99115 equals ( el . tabs ( 'option' , 'selected' ) , - 1 , 'should collapse tab passing in -1' ) ;
100-
116+
101117 el . tabs ( 'destroy' ) ;
102118 el . tabs ( { collapsible : true } ) ;
103119 el . tabs ( 'select' , null ) ;
104- equals ( el . tabs ( 'option' , 'selected' ) , - 1 , 'should collapse tab passing in null (deprecated)' ) ;
120+ equals ( el . tabs ( 'option' , 'selected' ) , - 1 , 'should collapse tab passing in null (deprecated)' ) ;
105121 el . tabs ( 'select' , null ) ;
106122 equals ( el . tabs ( 'option' , 'selected' ) , - 1 , 'should not select tab passing in null a second time (deprecated)' ) ;
107123
@@ -113,7 +129,7 @@ test('select', function() {
113129 equals ( el . tabs ( 'option' , 'selected' ) , 0 , 'should not collapse tab if collapsible is not set to true' ) ;
114130 el . tabs ( 'select' , null ) ;
115131 equals ( el . tabs ( 'option' , 'selected' ) , 0 , 'should not collapse tab if collapsible is not set to true' ) ;
116-
132+
117133 el . tabs ( 'select' , '#fragment-2' ) ;
118134 equals ( el . tabs ( 'option' , 'selected' ) , 1 , 'should select tab by id' ) ;
119135} ) ;
@@ -128,7 +144,7 @@ test('url', function() {
128144
129145test ( 'length' , function ( ) {
130146 expect ( 1 ) ;
131-
147+
132148 el = $ ( '#tabs1' ) . tabs ( ) ;
133149 equals ( el . tabs ( 'length' ) , $ ( 'ul a' , el ) . length , ' should return length' ) ;
134150} ) ;
0 commit comments