Free cookie consent management tool by TermsFeed Policy Generator

source: branches/WebApplication/MVC2/HeuristicLabWeb.PluginHost/HLWebPluginHost/Content/jQuery/jQueryPlugins/DataTables-1.7.6/media/unit_testing/tests_onhold/3_ajax/oSearch.js @ 6286

Last change on this file since 6286 was 6286, checked in by dkahn, 13 years ago

#1198 Added jQuery plus plugins

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