Add datatables-1.9.4 and jquery-1.10.2 libraries
[proteocache.git] / webapp / resources / datatables-1.9.4 / media / unit_testing / tests_onhold / 6_delayed_rendering / oLanguage.sLengthMenu.js
1 // DATA_TEMPLATE: empty_table
2 oTest.fnStart( "oLanguage.sLengthMenu" );
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                 "Menu language is 'Show _MENU_ entries' by default",
14                 null,
15                 function () { return oSettings.oLanguage.sLengthMenu == "Show _MENU_ entries"; }
16         );
17         
18         oTest.fnTest(
19                 "_MENU_ macro is replaced by select menu in DOM",
20                 null,
21                 function () { return $('select', oSettings.aanFeatures.l[0]).length == 1 }
22         );
23         
24         oTest.fnTest(
25                 "A label input is used",
26                 null,
27                 function () { return $('label', oSettings.aanFeatures.l[0]).length == 1 }
28         );
29         
30         oTest.fnTest(
31                 "Default is put into DOM",
32                 null,
33                 function () {
34                         var anChildren = $('label',oSettings.aanFeatures.l[0])[0].childNodes;
35                         var bReturn =
36                                 anChildren[0].nodeValue == "Show " &&
37                                 anChildren[2].nodeValue == " entries";
38                         return bReturn;
39                 }
40         );
41         
42         
43         oTest.fnWaitTest( 
44                 "Menu length language can be defined - no _MENU_ macro",
45                 function () {
46                         oSession.fnRestore();
47                         oTable = $('#example').dataTable( {
48                                 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
49                                 "bDeferRender": true,
50                                 "oLanguage": {
51                                         "sLengthMenu": "unit test"
52                                 }
53                         } );
54                         oSettings = oTable.fnSettings();
55                 },
56                 function () { return oSettings.oLanguage.sLengthMenu == "unit test"; }
57         );
58         
59         oTest.fnTest( 
60                 "Menu length language definition is in the DOM",
61                 null,
62                 function () {
63                         return $('label', oSettings.aanFeatures.l[0]).text() == "unit test";
64                 }
65         );
66         
67         
68         oTest.fnWaitTest( 
69                 "Menu length language can be defined - with _MENU_ macro",
70                 function () {
71                         oSession.fnRestore();
72                         oTable = $('#example').dataTable( {
73                                 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
74                                 "bDeferRender": true,
75                                 "oLanguage": {
76                                         "sLengthMenu": "unit _MENU_ test"
77                                 }
78                         } );
79                         oSettings = oTable.fnSettings();
80                 },
81                 function () {
82                         var anChildren = $('label',oSettings.aanFeatures.l[0])[0].childNodes;
83                         var bReturn =
84                                 anChildren[0].nodeValue == "unit " &&
85                                 anChildren[2].nodeValue == " test";
86                         return bReturn;
87                 }
88         );
89         
90         
91         oTest.fnWaitTest( 
92                 "Only the _MENU_ macro",
93                 function () {
94                         oSession.fnRestore();
95                         oTable = $('#example').dataTable( {
96                                 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
97                                 "bDeferRender": true,
98                                 "oLanguage": {
99                                         "sLengthMenu": "_MENU_"
100                                 }
101                         } );
102                         oSettings = oTable.fnSettings();
103                 },
104                 function () {
105                         var anChildren = oSettings.aanFeatures.l[0].childNodes;
106                         var bReturn =
107                                 anChildren.length == 1 &&
108                                 $('select', oSettings.aanFeatures.l[0]).length == 1;
109                         return bReturn;
110                 }
111         );
112         
113         
114         oTest.fnComplete();
115 } );