@@ -30,126 +30,159 @@ test("widget method", function() {
30
30
deepEqual ( $ ( "body > #ui-datepicker-div:last-child" ) [ 0 ] , actual ) ;
31
31
} ) ;
32
32
33
- test ( 'baseStructure' , function ( ) {
33
+ asyncTest ( 'baseStructure' , function ( ) {
34
34
expect ( 58 ) ;
35
35
var header , title , table , thead , week , panel , inl , child ,
36
- inp = TestHelpers . datepicker . init ( '#inp' ) . focus ( ) ,
36
+ inp = TestHelpers . datepicker . init ( '#inp' ) ,
37
37
dp = $ ( '#ui-datepicker-div' ) ;
38
- ok ( dp . is ( ':visible' ) , 'Structure - datepicker visible' ) ;
39
- ok ( ! dp . is ( '.ui-datepicker-rtl' ) , 'Structure - not right-to-left' ) ;
40
- ok ( ! dp . is ( '.ui-datepicker-multi' ) , 'Structure - not multi-month' ) ;
41
- equal ( dp . children ( ) . length , 2 , 'Structure - child count' ) ;
42
38
43
- header = dp . children ( ':first' ) ;
44
- ok ( header . is ( 'div.ui-datepicker-header' ) , 'Structure - header division' ) ;
45
- equal ( header . children ( ) . length , 3 , 'Structure - header child count' ) ;
46
- ok ( header . children ( ':first' ) . is ( 'a.ui-datepicker-prev' ) && header . children ( ':first' ) . html
8000
( ) !== '' , 'Structure - prev link' ) ;
47
- ok ( header . children ( ':eq(1)' ) . is ( 'a.ui-datepicker-next' ) && header . children ( ':eq(1)' ) . html ( ) !== '' , 'Structure - next link' ) ;
48
-
49
- title = header . children ( ':last' ) ;
50
- ok ( title . is ( 'div.ui-datepicker-title' ) && title . html ( ) !== '' , 'Structure - title division' ) ;
51
- equal ( title . children ( ) . length , 2 , 'Structure - title child count' ) ;
52
- ok ( title . children ( ':first' ) . is ( 'span.ui-datepicker-month' ) && title . children ( ':first' ) . text ( ) !== '' , 'Structure - month text' ) ;
53
- ok ( title . children ( ':last' ) . is ( 'span.ui-datepicker-year' ) && title . children ( ':last' ) . text ( ) !== '' , 'Structure - year text' ) ;
54
-
55
- table = dp . children ( ':eq(1)' ) ;
56
- ok ( table . is ( 'table.ui-datepicker-calendar' ) , 'Structure - month table' ) ;
57
- ok ( table . children ( ':first' ) . is ( 'thead' ) , 'Structure - month table thead' ) ;
58
- thead = table . children ( ':first' ) . children ( ':first' ) ;
59
- ok ( thead . is ( 'tr' ) , 'Structure - month table title row' ) ;
60
- equal ( thead . find ( 'th' ) . length , 7 , 'Structure - month table title cells' ) ;
61
- ok ( table . children ( ':eq(1)' ) . is ( 'tbody' ) , 'Structure - month table body' ) ;
62
- ok ( table . children ( ':eq(1)' ) . children ( 'tr' ) . length >= 4 , 'Structure - month table week count' ) ;
63
- week = table . children ( ':eq(1)' ) . children ( ':first' ) ;
64
- ok ( week . is ( 'tr' ) , 'Structure - month table week row' ) ;
65
- equal ( week . children ( ) . length , 7 , 'Structure - week child count' ) ;
66
- ok ( week . children ( ':first' ) . is ( 'td.ui-datepicker-week-end' ) , 'Structure - month table first day cell' ) ;
67
- ok ( week . children ( ':last' ) . is ( 'td.ui-datepicker-week-end' ) , 'Structure - month table second day cell' ) ;
68
- inp . datepicker ( 'hide' ) . datepicker ( 'destroy' ) ;
39
+ function step1 ( ) {
40
+ inp [ 0 ] . focus ( ) ;
41
+ setTimeout ( function ( ) {
42
+ ok ( dp . is ( ':visible' ) , 'Structure - datepicker visible' ) ;
43
+ ok ( ! dp . is ( '.ui-datepicker-rtl' ) , 'Structure - not right-to-left' ) ;
44
+ ok ( ! dp . is ( '.ui-datepicker-multi' ) , 'Structure - not multi-month' ) ;
45
+ equal ( dp . children ( ) . length , 2 , 'Structure - child count' ) ;
69
46
70
- // Editable month/year and button panel
71
- inp = TestHelpers . datepicker . init ( '#inp' , { changeMonth : true , changeYear : true , showButtonPanel : true } ) ;
72
- inp . focus ( ) ;
47
+ header = dp . children ( ':first' ) ;
48
+ ok ( header . is ( 'div.ui-datepicker-header' ) , 'Structure - header division' ) ;
49
+ equal ( header . children ( ) . length , 3 , 'Structure - header child count' ) ;
50
+ ok ( header . children ( ':first' ) . is ( 'a.ui-datepicker-prev' ) && header . children ( ':first' ) . html ( ) !== '' , 'Structure - prev link' ) ;
51
+ ok ( header . children ( ':eq(1)' ) . is ( 'a.ui-datepicker-next' ) && header . children ( ':eq(1)' ) . html ( ) !== '' , 'Structure - next link' ) ;
73
52
74
- title = dp . find ( 'div.ui-datepicker-title' ) ;
75
- ok ( title . children ( ':first' ) . is ( 'select.ui-datepicker-month' ) , 'Structure - month selector' ) ;
76
- ok ( title . children ( ':last' ) . is ( 'select.ui-datepicker-year' ) , 'Structure - year selector' ) ;
53
+ title = header . children ( ':last' ) ;
54
+ ok ( title . is ( 'div.ui-datepicker-title' ) && title . html ( ) !== '' , 'Structure - title division' ) ;
55
+ equal ( title . children ( ) . length , 2 , 'Structure - title child count' ) ;
56
+ ok ( title . children ( ':first' ) . is ( 'span.ui-datepicker-month' ) && title . children ( ':first' ) . text ( ) !== '' , 'Structure - month text' ) ;
57
+ ok ( title . children ( ':last' ) . is ( 'span.ui-datepicker-year' ) && title . children ( ':last' ) . text ( ) !== '' , 'Structure - year text' ) ;
77
58
78
- panel = dp . children ( ':last' ) ;
79
- ok ( panel . is ( 'div.ui-datepicker-buttonpane' ) , 'Structure - button panel division' ) ;
80
- equal ( panel . children ( ) . length , 2 , 'Structure - button panel child count' ) ;
81
- ok ( panel . children ( ':first' ) . is ( 'button.ui-datepicker-current' ) , 'Structure - today button' ) ;
82
- ok ( panel . children ( ':last' ) . is ( 'button.ui-datepicker-close' ) , 'Structure - close button' ) ;
83
- inp . datepicker ( 'hide' ) . datepicker ( 'destroy' ) ;
59
+ table = dp . children ( ':eq(1)' ) ;
60
+ ok ( table . is ( 'table.ui-datepicker-calendar' ) , 'Structure - month table' ) ;
61
+ ok ( table . children ( ':first' ) . is ( 'thead' ) , 'Structure - month table thead' ) ;
62
+ thead = table . children ( ':first' ) . children ( ':first' ) ;
63
+ ok ( thead . is ( 'tr' ) , 'Structure - month table title row' ) ;
64
+ equal ( thead . find ( 'th' ) . length , 7 , 'Structure - month table title cells' ) ;
65
+ ok ( table . children ( ':eq(1)' ) . is ( 'tbody' ) , 'Structure - month table body' ) ;
66
+ ok ( table . children ( ':eq(1)' ) . children ( 'tr' ) . length >= 4 , 'Structure - month table week count' ) ;
67
+ week = table . children ( ':eq(1)' ) . children ( ':first' ) ;
68
+ ok ( week . is ( 'tr' ) , 'Structure - month table week row' ) ;
69
+ equal ( week . children ( ) . length , 7 , 'Structure - week child count' ) ;
70
+ ok ( week . children ( ':first' ) . is ( 'td.ui-datepicker-week-end' ) , 'Structure - month table first day cell' ) ;
71
+ ok ( week . children ( ':last' ) . is ( 'td.ui-datepicker-week-end' ) , 'Structure - month table second day cell' ) ;
72
+ inp . datepicker ( 'hide' ) . datepicker ( 'destroy' ) ;
84
73
85
- // Multi-month 2
86
- inp = TestHelpers . datepicker . init ( '#inp' , { numberOfMonths : 2 } ) ;
87
- inp . focus ( ) ;
88
- ok ( dp . is ( '.ui-datepicker-multi' ) , 'Structure multi [2] - multi-month' ) ;
89
- equal ( dp . children ( ) . length , 3 , 'Structure multi [2] - child count' ) ;
90
- child = dp . children ( ':first' ) ;
91
- ok ( child . is ( 'div.ui-datepicker-group' ) && child . is ( 'div.ui-datepicker-group-first' ) , 'Structure multi [2] - first month division' ) ;
92
- child = dp . children ( ':eq(1)' ) ;
93
- ok ( child . is ( 'div.ui-datepicker-group' ) && child . is ( 'div.ui-datepicker-group-last' ) , 'Structure multi [2] - second month division' ) ;
94
- child = dp . children ( ':eq(2)' ) ;
95
- ok ( child . is ( 'div.ui-datepicker-row-break' ) , 'Structure multi [2] - row break' ) ;
96
- ok ( dp . is ( '.ui-datepicker-multi-2' ) , 'Structure multi [2] - multi-2' ) ;
97
- inp . datepicker ( 'hide' ) . datepicker ( 'destroy' ) ;
74
+ step2 ( ) ;
75
+ } ) ;
76
+ }
98
77
99
- // Multi-month 3
100
- inp = TestHelpers . datepicker . init ( '#inp' , { numberOfMonths : 3 } ) ;
101
- inp . focus ( ) ;
102
- ok ( dp . is ( '.ui-datepicker-multi-3' ) , 'Structure multi [3] - multi-3' ) ;
103
- ok ( ! dp . is ( '.ui-datepicker-multi-2' ) , 'Structure multi [3] - Trac #6704' ) ;
104
- inp . datepicker ( 'hide' ) . datepicker ( 'destroy' ) ;
78
+ function step2 ( ) {
79
+ // Editable month/year and button panel
80
+ inp = TestHelpers . datepicker . init ( '#inp' , { changeMonth : true , changeYear : true , showButtonPanel : true } ) ;
81
+ inp . focus ( ) ;
82
+ setTimeout ( function ( ) {
83
+ title = dp . find ( 'div.ui-datepicker-title' ) ;
84
+ ok ( title . children ( ':first' ) . is ( 'select.ui-datepicker-month' ) , 'Structure - month selector' ) ;
85
+ ok ( title . children ( ':last' ) . is ( 'select.ui-datepicker-year' ) , 'Structure - year selector' ) ;
105
86
106
- // Multi-month [2, 2]
107
- inp = TestHelpers . datepicker . init ( '#inp' , { numberOfMonths : [ 2 , 2 ] } ) ;
108
- inp . focus ( ) ;
109
- ok ( dp . is ( '.ui-datepicker-multi' ) , 'Structure multi - multi-month' ) ;
110
- equal ( dp . children ( ) . length , 6 , 'Structure multi [2,2] - child count' ) ;
111
- child = dp . children ( ':first' ) ;
112
- ok ( child . is ( 'div.ui-datepicker-group' ) && child . is ( 'div.ui-datepicker-group-first' ) , 'Structure multi [2,2] - first month division' ) ;
113
- child = dp . children ( ':eq(1)' ) ;
114
- ok ( child . is ( 'div.ui-datepicker-group' ) && child . is ( 'div.ui-datepicker-group-last' ) , 'Structure multi [2,2] - second month division' ) ;
115
- child = dp . children ( ':eq(2)' ) ;
116
- ok ( child . is ( 'div.ui-datepicker-row-break' ) , 'Structure multi [2,2] - row break' ) ;
117
- child = dp . children ( ':eq(3)' ) ;
118
- ok ( child . is ( 'div.ui-datepicker-group' ) && child . is ( 'div.ui-datepicker-group-first' ) , 'Structure multi [2,2] - third month division' ) ;
119
- child = dp . children ( ':eq(4)' ) ;
120
- ok ( child . is ( 'div.ui-datepicker-group' ) && child . is ( 'div.ui-datepicker-group-last' ) , 'Structure multi [2,2] - fourth month division' ) ;
121
- child = dp . children ( ':eq(5)' ) ;
122
- ok ( child . is ( 'div.ui-datepicker-row-break' ) , 'Structure multi [2,2] - row break' ) ;
123
- inp . datepicker ( 'hide' ) . datepicker ( 'destroy' ) ;
87
+ panel = dp . children ( ':last' ) ;
88
+ ok ( panel . is ( 'div.ui-datepicker-buttonpane' ) , 'Structure - button panel division' ) ;
89
+ equal ( panel . children ( ) . length , 2 , 'Structure - button panel child count' ) ;
90
+ ok ( panel . children ( ':first' ) . is ( 'button.ui-datepicker-current' ) , 'Structure - today button' ) ;
91
+ ok ( panel . children ( ':last' ) . is ( 'button.ui-datepicker-close' ) , 'Structure - close button' ) ;
92
+ inp . datepicker ( 'hide' ) . datepicker ( 'destroy' ) ;
124
93
125
- // Inline
126
- inl = TestHelpers . datepicker . init ( '#inl' ) ;
127
- dp = inl . children ( ) ;
128
- ok ( dp . is ( '.ui-datepicker-inline' ) , 'Structure inline - main div' ) ;
129
- ok ( ! dp . is ( '.ui-datepicker-rtl' ) , 'Structure inline - not right-to-left' ) ;
130
- ok ( ! dp . is ( '.ui-datepicker-multi' ) , 'Structure inline - not multi-month' ) ;
131
- equal ( dp . children ( ) . length , 2 , 'Structure inline - child count' ) ;
132
- header = dp . children ( ':first' ) ;
133
- ok ( header . is ( 'div.ui-datepicker-header' ) , 'Structure inline - header division' ) ;
134
- equal ( header . children ( ) . length , 3 , 'Structure inline - header child count' ) ;
135
- table = dp . children ( ':eq(1)' ) ;
136
- ok ( table . is ( 'table.ui-datepicker-calendar' ) , 'Structure inline - month table' ) ;
137
- ok ( table . children ( ':first' ) . is ( 'thead' ) , 'Structure inline - month table thead' ) ;
138
- ok ( table . children ( ':eq(1)' ) . is ( 'tbody' ) , 'Structure inline - month table body' ) ;
139
- inl . datepicker ( 'destroy' ) ;
140
-
141
- // Inline multi-month
142
- inl = TestHelpers . datepicker . init ( '#inl' , { numberOfMonths : 2 } ) ;
143
- dp = inl . children ( ) ;
144
- ok ( dp . is ( '.ui-datepicker-inline' ) && dp . is ( '.ui-datepicker-multi' ) , 'Structure inline multi - main div' ) ;
145
- equal ( dp . children ( ) . length , 3 , 'Structure inline multi - child count' ) ;
146
- child = dp . children ( ':first' ) ;
147
- ok ( child . is ( 'div.ui-datepicker-group' ) && child . is ( 'div.ui-datepicker-group-first' ) , 'Structure inline multi - first month division' ) ;
148
- child = dp . children ( ':eq(1)' ) ;
149
- ok ( child . is ( 'div.ui-datepicker-group' ) && child . is ( 'div.ui-datepicker-group-last' ) , 'Structure inline multi - second month division' ) ;
150
- child = dp . children ( ':eq(2)' ) ;
151
- ok ( child . is ( 'div.ui-datepicker-row-break' ) , 'Structure inline multi - row break' ) ;
152
- inl . datepicker ( 'destroy' ) ;
94
+ step3 ( ) ;
95
+ } ) ;
96
+ }
97
+
98
+ function step3 ( ) {
99
+ // Multi-month 2
100
+ inp = TestHelpers . datepicker . init ( '#inp' , { numberOfMonths : 2 } ) ;
101
+ inp . focus ( ) ;
102
+ setTimeout ( function ( ) {
103
+ ok ( dp . is ( '.ui-datepicker-multi' ) , 'Structure multi [2] - multi-month' ) ;
104
+ equal ( dp . children ( ) . length , 3 , 'Structure multi [2] - child count' ) ;
105
+ child = dp . children ( ':first' ) ;
106
+ ok ( child . is ( 'div.ui-datepicker-group' ) && child . is ( 'div.ui-datepicker-group-first' ) , 'Structure multi [2] - first month division' ) ;
107
+ child = dp . children ( ':eq(1)' ) ;
108
+ ok ( child . is ( 'div.ui-datepicker-group' ) && child . is ( 'div.ui-datepicker-group-last' ) , 'Structure multi [2] - second month division' ) ;
109
+ child = dp . children ( ':eq(2)' ) ;
110
+ ok ( child . is ( 'div.ui-datepicker-row-break' ) , 'Structure multi [2] - row break' ) ;
111
+ ok ( dp . is ( '.ui-datepicker-multi-2' ) , 'Structure multi [2] - multi-2' ) ;
112
+ inp . datepicker ( 'hide' ) . datepicker ( 'destroy' ) ;
113
+
114
+ step4 ( ) ;
115
+ } ) ;
116
+ }
117
+
118
+ function step4 ( ) {
119
+ // Multi-month 3
120
+ inp = TestHelpers . datepicker . init ( '#inp' , { numberOfMonths : 3 } ) ;
121
+ inp . focus ( ) ;
122
+ setTimeout ( function ( ) {
123
+ ok ( dp . is ( '.ui-datepicker-multi-3' ) , 'Structure multi [3] - multi-3' ) ;
124
+ ok ( ! dp . is ( '.ui-datepicker-multi-2' ) , 'Structure multi [3] - Trac #6704' ) ;
125
+ inp . datepicker ( 'hide' ) . datepicker ( 'destroy' ) ;
126
+
127
+ step5 ( ) ;
128
+ } ) ;
129
+ }
130
+
131
+ function step5 ( ) {
132
+ // Multi-month [2, 2]
133
+ inp = TestHelpers . datepicker . init ( '#inp' , { numberOfMonths : [ 2 , 2 ] } ) ;
134
+ inp . focus ( ) ;
135
+ setTimeout ( function ( ) {
136
+ ok ( dp . is ( '.ui-datepicker-multi' ) , 'Structure multi - multi-month' ) ;
137
+ equal ( dp . children ( ) . length , 6 , 'Structure multi [2,2] - child count' ) ;
138
+ child = dp . children ( ':first' ) ;
139
+ ok ( child . is ( 'div.ui-datepicker-group' ) && child . is ( 'div.ui-datepicker-group-first' ) , 'Structure multi [2,2] - first month division' ) ;
140
+ child = dp . children ( ':eq(1)' ) ;
141
+ ok ( child . is ( 'div.ui-datepicker-group' ) && child . is ( 'div.ui-datepicker-group-last' ) , 'Structure multi [2,2] - second month division' ) ;
142
+ child = dp . children ( ':eq(2)' ) ;
143
+ ok ( child . is ( 'div.ui-datepicker-row-break' ) , 'Structure multi [2,2] - row break' ) ;
144
+ child = dp . children ( ':eq(3)' ) ;
145
+ ok ( child . is ( 'div.ui-datepicker-group' ) && child . is ( 'div.ui-datepicker-group-first' ) , 'Structure multi [2,2] - third month division' ) ;
146
+ child = dp . children ( ':eq(4)' ) ;
147
+ ok ( child . is ( 'div.ui-datepicker-group' ) && child . is ( 'div.ui-datepicker-group-last' ) , 'Structure multi [2,2] - fourth month division' ) ;
148
+ child = dp . children ( ':eq(5)' ) ;
149
+ ok ( child . is ( 'div.ui-datepicker-row-break' ) , 'Structure multi [2,2] - row break' ) ;
150
+ inp . datepicker ( 'hide' ) . datepicker ( 'destroy' ) ;
151
+
152
+ // Inline
153
+ inl = TestHelpers . datepicker . init ( '#inl' ) ;
154
+ dp = inl . children ( ) ;
155
+ ok ( dp . is ( '.ui-datepicker-inline' ) , 'Structure inline - main div' ) ;
156
+ ok ( ! dp . is ( '.ui-datepicker-rtl' ) , 'Structure inline - not right-to-left' ) ;
157
+ ok ( ! dp . is ( '.ui-datepicker-multi' ) , 'Structure inline - not multi-month' ) ;
158
+ equal ( dp . children ( ) . length , 2 , 'Structure inline - child count' ) ;
159
+ header = dp . children ( ':first' ) ;
160
+ ok ( header . is ( 'div.ui-datepicker-header' ) , 'Structure inline - header division' ) ;
161
+ equal ( header . children ( ) . length , 3 , 'Structure inline - header child count' ) ;
162
+ table = dp . children ( ':eq(1)' ) ;
163
+ ok ( table . is ( 'table.ui-datepicker-calendar' ) , 'Structure inline - month table' ) ;
164
+ ok ( table . children ( ':first' ) . is ( 'thead' ) , 'Structure inline - month table thead' ) ;
165
+ ok ( table . children ( ':eq(1)' ) . is ( 'tbody' ) , 'Structure inline - month table body' ) ;
166
+ inl . datepicker ( 'destroy' ) ;
167
+
168
+ // Inline multi-month
169
+ inl = TestHelpers . datepicker . init ( '#inl' , { numberOfMonths : 2 } ) ;
170
+ dp = inl . children ( ) ;
171
+ ok ( dp . is ( '.ui-datepicker-inline' ) && dp . is ( '.ui-datepicker-multi' ) , 'Structure inline multi - main div' ) ;
172
+ equal ( dp . children ( ) . length , 3 , 'Structure inline multi - child count' ) ;
173
+ child = dp . children ( ':first' ) ;
174
+ ok ( child . is ( 'div.ui-datepicker-group' ) && child . is ( 'div.ui-datepicker-group-first' ) , 'Structure inline multi - first month division' ) ;
175
+ child = dp . children ( ':eq(1)' ) ;
176
+ ok ( child . is ( 'div.ui-datepicker-group' ) && child . is ( 'div.ui-datepicker-group-last' ) , 'Structure inline multi - second month division' ) ;
177
+ child = dp . children ( ':eq(2)' ) ;
178
+ ok ( child . is ( 'div.ui-datepicker-row-break' ) , 'Structure inline multi - row break' ) ;
179
+ inl . datepicker ( 'destroy' ) ;
180
+
181
+ start ( ) ;
182
+ } ) ;
183
+ }
184
+
185
+ step1 (<
4771
/span>) ;
153
186
} ) ;
154
187
155
188
test ( 'customStructure' , function ( ) {
0 commit comments