Index: trunk/phase3/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js |
— | — | @@ -3,10 +3,11 @@ |
4 | 4 | module( 'jquery.tablesorter' ); |
5 | 5 | |
6 | 6 | // setup hack |
7 | | -mw.config.set( 'wgMonthNames', ['', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']); |
8 | | -mw.config.set( 'wgMonthNamesShort', ['', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']); |
| 7 | +mw.config.set( 'wgMonthNames', [ '', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ] ); |
| 8 | +mw.config.set( 'wgMonthNamesShort', ['', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] ); |
9 | 9 | mw.config.set( 'wgDefaultDateFormat', 'dmy' ); |
10 | 10 | |
| 11 | + |
11 | 12 | test( '-- Initial check', function() { |
12 | 13 | expect(1); |
13 | 14 | ok( $.tablesorter, '$.tablesorter defined' ); |
— | — | @@ -23,8 +24,9 @@ |
24 | 25 | var tableCreate = function( header, data ) { |
25 | 26 | var $table = $( '<table class="sortable"><thead></thead><tbody></tbody></table>' ), |
26 | 27 | $thead = $table.find( 'thead' ), |
27 | | - $tbody = $table.find( 'tbody' ); |
28 | | - var $tr = $( '<tr>' ); |
| 28 | + $tbody = $table.find( 'tbody' ), |
| 29 | + $tr = $( '<tr>' ); |
| 30 | + |
29 | 31 | $.each( header, function( i, str ) { |
30 | 32 | var $th = $( '<th>' ); |
31 | 33 | $th.text( str ).appendTo( $tr ); |
— | — | @@ -50,6 +52,7 @@ |
51 | 53 | */ |
52 | 54 | var tableExtract = function( $table ) { |
53 | 55 | var data = []; |
| 56 | + |
54 | 57 | $table.find( 'tbody' ).find( 'tr' ).each( function( i, tr ) { |
55 | 58 | var row = []; |
56 | 59 | $( tr ).find( 'td,th' ).each( function( i, td ) { |
— | — | @@ -93,18 +96,18 @@ |
94 | 97 | return arr2; |
95 | 98 | }; |
96 | 99 | |
97 | | -// Sample data set: some planets! |
98 | | -var header = ['Planet', 'Radius (km)'], |
99 | | - mercury = ['Mercury', '2439.7'], |
100 | | - venus = ['Venus', '6051.8'], |
101 | | - earth = ['Earth', '6371.0'], |
102 | | - mars = ['Mars', '3390.0'], |
103 | | - jupiter = ['Jupiter', '69911'], |
104 | | - saturn = ['Saturn', '58232']; |
| 100 | +// Sample data set using planets named and their radius |
| 101 | +var header = [ 'Planet' , 'Radius (km)'], |
| 102 | + mercury = [ 'Mercury', '2439.7' ], |
| 103 | + venus = [ 'Venus' , '6051.8' ], |
| 104 | + earth = [ 'Earth' , '6371.0' ], |
| 105 | + mars = [ 'Mars' , '3390.0' ], |
| 106 | + jupiter = [ 'Jupiter', '69911' ], |
| 107 | + saturn = [ 'Saturn' , '58232' ]; |
105 | 108 | |
106 | 109 | // Initial data set |
107 | | -var planets = [mercury, venus, earth, mars, jupiter, saturn]; |
108 | | -var ascendingName = [earth, jupiter, mars, mercury, saturn, venus]; |
| 110 | +var planets = [mercury, venus, earth, mars, jupiter, saturn]; |
| 111 | +var ascendingName = [earth, jupiter, mars, mercury, saturn, venus]; |
109 | 112 | var ascendingRadius = [mercury, mars, venus, earth, saturn, jupiter]; |
110 | 113 | |
111 | 114 | tableTest( |
— | — | @@ -161,18 +164,16 @@ |
162 | 165 | |
163 | 166 | // Regression tests! |
164 | 167 | tableTest( |
165 | | - 'Bug 28775: German-style short numeric dates', |
| 168 | + 'Bug 28775: German-style (dmy) short numeric dates', |
166 | 169 | ['Date'], |
167 | | - [ |
168 | | - // German-style dates are day-month-year |
| 170 | + [ // German-style dates are day-month-year |
169 | 171 | ['11.11.2011'], |
170 | 172 | ['01.11.2011'], |
171 | 173 | ['02.10.2011'], |
172 | 174 | ['03.08.2011'], |
173 | 175 | ['09.11.2011'] |
174 | 176 | ], |
175 | | - [ |
176 | | - // Sorted by ascending date |
| 177 | + [ // Sorted by ascending date |
177 | 178 | ['03.08.2011'], |
178 | 179 | ['02.10.2011'], |
179 | 180 | ['01.11.2011'], |
— | — | @@ -186,19 +187,18 @@ |
187 | 188 | $table.find( '.headerSort:eq(0)' ).click(); |
188 | 189 | } |
189 | 190 | ); |
| 191 | + |
190 | 192 | tableTest( |
191 | | - 'Bug 28775: American-style short numeric dates', |
| 193 | + 'Bug 28775: American-style (mdy) short numeric dates', |
192 | 194 | ['Date'], |
193 | | - [ |
194 | | - // American-style dates are month-day-year |
| 195 | + [ // American-style dates are month-day-year |
195 | 196 | ['11.11.2011'], |
196 | 197 | ['01.11.2011'], |
197 | 198 | ['02.10.2011'], |
198 | 199 | ['03.08.2011'], |
199 | 200 | ['09.11.2011'] |
200 | 201 | ], |
201 | | - [ |
202 | | - // Sorted by ascending date |
| 202 | + [ // Sorted by ascending date |
203 | 203 | ['01.11.2011'], |
204 | 204 | ['02.10.2011'], |
205 | 205 | ['03.08.2011'], |
— | — | @@ -235,6 +235,7 @@ |
236 | 236 | ['204.204.132.158'], |
237 | 237 | ['247.240.82.209'] |
238 | 238 | ]; |
| 239 | + |
239 | 240 | tableTest( |
240 | 241 | 'Bug 17141: IPv4 address sorting', |
241 | 242 | ['IP'], |
— | — | @@ -288,7 +289,7 @@ |
289 | 290 | function( $table ) { |
290 | 291 | mw.config.set( 'tableSorterCollation', { |
291 | 292 | 'ä': 'ae', |
292 | | - 'ö' : 'oe', |
| 293 | + 'ö': 'oe', |
293 | 294 | 'ß': 'ss', |
294 | 295 | 'ü':'ue' |
295 | 296 | } ); |
— | — | @@ -302,7 +303,7 @@ |
303 | 304 | var planetsRowspanII = [jupiter, mercury, saturn, ['Venus', '6371.0'], venus, ['Venus', '3390.0']]; |
304 | 305 | |
305 | 306 | tableTest( |
306 | | - 'Basic planet table: Same value for multiple rows via rowspan', |
| 307 | + 'Basic planet table: same value for multiple rows via rowspan', |
307 | 308 | header, |
308 | 309 | planets, |
309 | 310 | planetsRowspan, |