1 |
// DATA_TEMPLATE: dom_data |
2 |
oTest.fnStart( "oSearch" ); |
3 |
|
4 |
$(document).ready( function () { |
5 |
/* Check the default */ |
6 |
var oTable = $('#example').dataTable(); |
7 |
var oSettings = oTable.fnSettings(); |
8 |
|
9 |
oTest.fnTest( |
10 |
"Default values should be blank", |
11 |
null, |
12 |
function () { |
13 |
var bReturn = oSettings.oPreviousSearch.sSearch == "" && |
14 |
!oSettings.oPreviousSearch.bRegex; |
15 |
return bReturn; |
16 |
} |
17 |
); |
18 |
|
19 |
/* This test might be considered iffy since the full object isn't given, but it's reasonable to |
20 |
* expect DataTables to cope with this. It should just assumine regex false |
21 |
*/ |
22 |
oTest.fnTest( |
23 |
"Search term only in object", |
24 |
function () { |
25 |
oSession.fnRestore(); |
26 |
oTable = $('#example').dataTable( { |
27 |
"oSearch": { |
28 |
"sSearch": "Mozilla" |
29 |
} |
30 |
} ); |
31 |
}, |
32 |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Gecko"; } |
33 |
); |
34 |
|
35 |
oTest.fnTest( |
36 |
"New search will kill old one", |
37 |
function () { |
38 |
oTable.fnFilter("Opera"); |
39 |
}, |
40 |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Presto"; } |
41 |
); |
42 |
|
43 |
oTest.fnTest( |
44 |
"Search plain text term and escape regex true", |
45 |
function () { |
46 |
oSession.fnRestore(); |
47 |
$('#example').dataTable( { |
48 |
"oSearch": { |
49 |
"sSearch": "DS", |
50 |
"bRegex": false |
51 |
} |
52 |
} ); |
53 |
}, |
54 |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Nintendo DS browser"; } |
55 |
); |
56 |
|
57 |
oTest.fnTest( |
58 |
"Search plain text term and escape regex false", |
59 |
function () { |
60 |
oSession.fnRestore(); |
61 |
$('#example').dataTable( { |
62 |
"oSearch": { |
63 |
"sSearch": "Opera", |
64 |
"bRegex": true |
65 |
} |
66 |
} ); |
67 |
}, |
68 |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Presto"; } |
69 |
); |
70 |
|
71 |
oTest.fnTest( |
72 |
"Search regex text term and escape regex true", |
73 |
function () { |
74 |
oSession.fnRestore(); |
75 |
$('#example').dataTable( { |
76 |
"oSearch": { |
77 |
"sSearch": "1.*", |
78 |
"bRegex": false |
79 |
} |
80 |
} ); |
81 |
}, |
82 |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "No matching records found"; } |
83 |
); |
84 |
|
85 |
oTest.fnTest( |
86 |
"Search regex text term and escape regex false", |
87 |
function () { |
88 |
oSession.fnRestore(); |
89 |
$('#example').dataTable( { |
90 |
"oSearch": { |
91 |
"sSearch": "1.*", |
92 |
"bRegex": true |
93 |
} |
94 |
} ); |
95 |
}, |
96 |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Gecko"; } |
97 |
); |
98 |
|
99 |
|
100 |
oTest.fnComplete(); |
101 |
} ); |