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