annotate DataTables-1.9.4/media/unit_testing/tests_onhold/6_delayed_rendering/oLanguage.sLengthMenu.js @ 9:7300ed4c1481 draft default tip

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