@@ -9,7 +9,7 @@ test('init', function() {
9
9
expect ( 9 ) ;
10
10
11
11
el = $ ( '#tabs1' ) . tabs ( ) ;
12
-
12
+
13
13
ok ( true , '.tabs() called on element' ) ;
14
14
ok ( el . is ( '.ui-tabs.ui-widget.ui-widget-content.ui-corner-all' ) , 'attach classes to container' ) ;
15
15
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() {
23
23
24
24
test ( 'destroy' , function ( ) {
25
25
expect ( 6 ) ;
26
-
26
+
27
27
el = $ ( '#tabs1' ) . tabs ( { collapsible : true } ) ;
28
28
$ ( 'li:eq(2)' , el ) . simulate ( 'mouseover' ) . find ( 'a' ) . focus ( ) ;
29
29
el . tabs ( 'destroy' ) ;
30
-
30
+
31
31
ok ( el . is ( ':not(.ui-tabs, .ui-widget, .ui-widget-content, .ui-corner-all, .ui-tabs-collapsible)' ) , 'remove classes from container' ) ;
32
32
ok ( $ ( 'ul' , el ) . is ( ':not(.ui-tabs-nav, .ui-helper-reset, .ui-helper-clearfix, .ui-widget-header, .ui-corner-all)' ) , 'remove classes from list' ) ;
33
33
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' ) ;
35
35
ok ( $ ( 'li:eq(1)' , el ) . is ( ':not(.ui-state-default, .ui-corner-top)' ) , 'remove classes from inactive li' ) ;
36
36
ok ( $ ( 'li:eq(2)' , el ) . is ( ':not(.ui-state-hover, .ui-state-focus)' ) , 'remove classes from mouseovered or focused li' ) ;
37
37
} ) ;
38
38
39
39
test ( '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' ) ;
41
46
} ) ;
42
47
43
48
test ( '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' ) ;
45
61
} ) ;
46
62
47
63
test ( 'add' , function ( ) {
48
64
expect ( 4 ) ;
49
-
65
+
50
66
el = $ ( '#tabs1' ) . tabs ( ) ;
51
- el . tabs ( 'add' , " #new" , 'New' ) ;
67
+ el . tabs ( 'add' , ' #new' , 'New' ) ;
52
68
53
69
var added = $ ( 'li:last' , el ) . simulate ( 'mouseover' ) ;
54
70
ok ( added . is ( '.ui-state-hover' ) , 'should add mouseover handler to added tab' ) ;
55
71
added . simulate ( 'mouseout' ) ;
56
72
var other = $ ( 'li:first' , el ) . simulate ( 'mouseover' ) ;
57
73
ok ( other . is ( '.ui-state-hover' ) , 'should not remove mouseover handler from existing tab' ) ;
58
74
other . simulate ( 'mouseout' ) ;
59
-
75
+
60
76
equals ( $ ( 'a' , added ) . attr ( 'href' ) , '#new' , 'should not expand href to full url of current page' ) ;
61
-
77
+
62
78
ok ( false , "missing test - untested code is broken code." ) ;
63
79
} ) ;
64
80
65
81
test ( 'remove' , function ( ) {
66
82
expect ( 4 ) ;
67
83
68
84
el = $ ( '#tabs1' ) . tabs ( ) ;
69
-
85
+
70
86
el . tabs ( 'remove' , 0 ) ;
71
87
equals ( el . tabs ( 'length' ) , 2 , 'remove tab' ) ;
72
88
equals ( $ ( 'li a[href$="fragment-1"]' , el ) . length , 0 , 'remove associated list item' ) ;
73
89
equals ( $ ( '#fragment-1' ) . length , 0 , 'remove associated panel' ) ;
74
-
90
+
75
91
// TODO delete tab -> focus tab to right
76
92
// TODO delete last tab -> focus tab to left
77
-
93
+
78
94
el . tabs ( 'select' , 1 ) ;
79
95
el . tabs ( 'remove' , 1 ) ;
80
- equals ( el . tabs ( 'option' , 'selected' ) , 0 , 'update selected property' ) ;
96
+ equals ( el . tabs ( 'option' , 'selected' ) , 0 , 'update selected property' ) ;
81
97
} ) ;
82
98
83
99
test ( 'select' , function ( ) {
84
100
expect ( 9 ) ;
85
-
101
+
86
102
el = $ ( '#tabs1' ) . tabs ( ) ;
87
-
103
+
88
104
el . tabs ( 'select' , 1 ) ;
89
105
equals ( el . tabs ( 'option' , 'selected' ) , 1 , 'should select tab' ) ;
90
106
@@ -97,11 +113,11 @@ test('select', function() {
97
113
el . tabs ( { collapsible : true } ) ;
98
114
el . tabs ( 'select' , - 1 ) ;
99
115
equals ( el . tabs ( 'option' , 'selected' ) , - 1 , 'should collapse tab passing in -1' ) ;
100
-
116
+
101
117
el . tabs ( 'destroy' ) ;
102
118
el . tabs ( { collapsible : true } ) ;
103
119
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)' ) ;
105
121
el . tabs ( 'select' , null ) ;
106
122
equals ( el . tabs ( 'option' , 'selected' ) , - 1 , 'should not select tab passing in null a second time (deprecated)' ) ;
107
123
@@ -113,7 +129,7 @@ test('select', function() {
113
129
equals ( el . tabs ( 'option' , 'selected' ) , 0 , 'should not collapse tab if collapsible is not set to true' ) ;
114
130
el . tabs ( 'select' , null ) ;
115
131
equals ( el . tabs ( 'option' , 'selected' ) , 0 , 'should not collapse tab if collapsible is not set to true' ) ;
116
-
132
+
117
133
el . tabs ( 'select' , '#fragment-2' ) ;
118
134
equals ( el . tabs ( 'option' , 'selected' ) , 1 , 'should select tab by id' ) ;
119
135
} ) ;
@@ -128,7 +144,7 @@ test('url', function() {
128
144
129
145
test ( 'length' , function ( ) {
130
146
expect ( 1 ) ;
131
-
147
+
132
148
el = $ ( '#tabs1' ) . tabs ( ) ;
133
149
equals ( el . tabs ( 'length' ) , $ ( 'ul a' , el ) . length , ' should return length' ) ;
134
150
} ) ;
0 commit comments