1 |
// DATA_TEMPLATE: dom_data |
2 |
oTest.fnStart( "aoSearchCols" ); |
3 |
|
4 |
/* We could be here forever testing this one, so we test a limited subset on a couple of colums */ |
5 |
|
6 |
$(document).ready( function () { |
7 |
/* Check the default */ |
8 |
var oTable = $('#example').dataTable(); |
9 |
var oSettings = oTable.fnSettings(); |
10 |
|
11 |
oTest.fnTest( |
12 |
"Default should be to have a empty colums array", |
13 |
null, |
14 |
function () { |
15 |
var bReturn = |
16 |
oSettings.aoPreSearchCols[0].sSearch == 0 && !oSettings.aoPreSearchCols[0].bRegex && |
17 |
oSettings.aoPreSearchCols[1].sSearch == 0 && !oSettings.aoPreSearchCols[1].bRegex && |
18 |
oSettings.aoPreSearchCols[2].sSearch == 0 && !oSettings.aoPreSearchCols[2].bRegex && |
19 |
oSettings.aoPreSearchCols[3].sSearch == 0 && !oSettings.aoPreSearchCols[3].bRegex && |
20 |
oSettings.aoPreSearchCols[4].sSearch == 0 && !oSettings.aoPreSearchCols[4].bRegex; |
21 |
return bReturn; |
22 |
} |
23 |
); |
24 |
|
25 |
|
26 |
oTest.fnTest( |
27 |
"Search on a single column - no regex statement given", |
28 |
function () { |
29 |
oSession.fnRestore(); |
30 |
oTable = $('#example').dataTable( { |
31 |
"aoSearchCols": [ |
32 |
null, |
33 |
{ "sSearch": "Mozilla" }, |
34 |
null, |
35 |
{ "sSearch": "1" }, |
36 |
null |
37 |
] |
38 |
} ); |
39 |
}, |
40 |
function () { return $('#example_info').html() == "Showing 1 to 9 of 9 entries (filtered from 57 total entries)"; } |
41 |
); |
42 |
|
43 |
oTest.fnTest( |
44 |
"Search on two columns - no regex statement given", |
45 |
function () { |
46 |
oSession.fnRestore(); |
47 |
oTable = $('#example').dataTable( { |
48 |
"aoSearchCols": [ |
49 |
null, |
50 |
{ "sSearch": "Mozilla" }, |
51 |
null, |
52 |
{ "sSearch": "1.5" }, |
53 |
null |
54 |
] |
55 |
} ); |
56 |
}, |
57 |
function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == "1.5"; } |
58 |
); |
59 |
|
60 |
oTest.fnTest( |
61 |
"Search on single column - escape regex false", |
62 |
function () { |
63 |
oSession.fnRestore(); |
64 |
oTable = $('#example').dataTable( { |
65 |
"aoSearchCols": [ |
66 |
{ "sSearch": ".*ML", "bEscapeRegex": false }, |
67 |
null, |
68 |
null, |
69 |
null, |
70 |
null |
71 |
] |
72 |
} ); |
73 |
}, |
74 |
function () { return $('#example_info').html() == "Showing 1 to 3 of 3 entries (filtered from 57 total entries)"; } |
75 |
); |
76 |
|
77 |
oTest.fnTest( |
78 |
"Search on two columns - escape regex false on first, true on second", |
79 |
function () { |
80 |
oSession.fnRestore(); |
81 |
oTable = $('#example').dataTable( { |
82 |
"aoSearchCols": [ |
83 |
{ "sSearch": ".*ML", "bEscapeRegex": false }, |
84 |
{ "sSearch": "3.3", "bEscapeRegex": true }, |
85 |
null, |
86 |
null, |
87 |
null |
88 |
] |
89 |
} ); |
90 |
}, |
91 |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Konqureror 3.3"; } |
92 |
); |
93 |
|
94 |
oTest.fnTest( |
95 |
"Search on two columns (no records) - escape regex false on first, true on second", |
96 |
function () { |
97 |
oSession.fnRestore(); |
98 |
oTable = $('#example').dataTable( { |
99 |
"aoSearchCols": [ |
100 |
{ "sSearch": ".*ML", "bEscapeRegex": false }, |
101 |
{ "sSearch": "Allan", "bEscapeRegex": true }, |
102 |
null, |
103 |
null, |
104 |
null |
105 |
] |
106 |
} ); |
107 |
}, |
108 |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "No matching records found"; } |
109 |
); |
110 |
|
111 |
oTest.fnComplete(); |
112 |
} ); |