annotate DataTables-1.9.4/media/unit_testing/tests_onhold/6_delayed_rendering/oSearch.js @ 7:0f2b740536fb draft

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