1 |
// DATA_TEMPLATE: dom_data |
2 |
oTest.fnStart( "bSort" ); |
3 |
|
4 |
$(document).ready( function () { |
5 |
/* Check the default */ |
6 |
$('#example').dataTable(); |
7 |
|
8 |
oTest.fnTest( |
9 |
"Sorting is on by default", |
10 |
null, |
11 |
function () { return $('#example tbody td:eq(0)').html() == "Gecko"; } |
12 |
); |
13 |
|
14 |
oTest.fnTest( |
15 |
"Sorting Asc by default class applied", |
16 |
null, |
17 |
function () { return $('#example thead th:eq(0)').hasClass("sorting_asc"); } |
18 |
); |
19 |
|
20 |
oTest.fnTest( |
21 |
"Click on second column", |
22 |
function () { $('#example thead th:eq(1)').click(); }, |
23 |
function () { return $('#example tbody td:eq(1)').html() == "All others"; } |
24 |
); |
25 |
|
26 |
oTest.fnTest( |
27 |
"Sorting class removed from first column", |
28 |
null, |
29 |
function () { return $('#example thead th:eq(0)').hasClass("sorting_asc") != true; } |
30 |
); |
31 |
|
32 |
oTest.fnTest( |
33 |
"Sorting asc class applied to second column", |
34 |
null, |
35 |
function () { return $('#example thead th:eq(1)').hasClass("sorting_asc"); } |
36 |
); |
37 |
|
38 |
oTest.fnTest( |
39 |
"Reverse on second column", |
40 |
function () { $('#example thead th:eq(1)').click(); }, |
41 |
function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; } |
42 |
); |
43 |
|
44 |
oTest.fnTest( |
45 |
"Sorting acs class removed from second column", |
46 |
null, |
47 |
function () { return $('#example thead th:eq(1)').hasClass("sorting_asc") != true; } |
48 |
); |
49 |
|
50 |
oTest.fnTest( |
51 |
"Sorting desc class applied to second column", |
52 |
null, |
53 |
function () { return $('#example thead th:eq(1)').hasClass("sorting_desc"); } |
54 |
); |
55 |
|
56 |
/* Check can disable */ |
57 |
oTest.fnTest( |
58 |
"Pagiantion can be disabled", |
59 |
function () { |
60 |
oSession.fnRestore(); |
61 |
$('#example').dataTable( { |
62 |
"bSort": false |
63 |
} ); |
64 |
}, |
65 |
function () { return $('#example tbody td:eq(3)').html() == "4"; } |
66 |
); |
67 |
|
68 |
oTest.fnTest( |
69 |
"Disabled classes applied", |
70 |
null, |
71 |
function () { return $('#example thead th:eq(0)').hasClass('sorting_disabled'); } |
72 |
); |
73 |
|
74 |
oTest.fnTest( |
75 |
"Click on second column has no effect", |
76 |
function () { $('#example thead th:eq(1)').click(); }, |
77 |
function () { return $('#example tbody td:eq(3)').html() == "4"; } |
78 |
); |
79 |
|
80 |
oTest.fnTest( |
81 |
"Reverse on second column has no effect", |
82 |
function () { $('#example thead th:eq(1)').click(); }, |
83 |
function () { return $('#example tbody td:eq(3)').html() == "4"; } |
84 |
); |
85 |
|
86 |
/* Enable makes no difference */ |
87 |
oTest.fnTest( |
88 |
"Sorting enabled override", |
89 |
function () { |
90 |
oSession.fnRestore(); |
91 |
$('#example').dataTable( { |
92 |
"bSort": true |
93 |
} ); |
94 |
}, |
95 |
function () { return $('#example tbody td:eq(0)').html() == "Gecko"; } |
96 |
); |
97 |
|
98 |
|
99 |
|
100 |
oTest.fnComplete(); |
101 |
} ); |