File: language_lengthMenu.js

package info (click to toggle)
datatables.js 1.11.5%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 22,848 kB
  • sloc: javascript: 65,075; xml: 10,712; php: 4,741; sh: 544; makefile: 18
file content (58 lines) | stat: -rw-r--r-- 2,309 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
describe( "language.lengthMenu option", function() {
	dt.libs( {
		js:  [ 'jquery', 'datatables' ],
		css: [ 'datatables' ]
	} );

	describe("Check the defaults", function () {
		dt.html( 'basic' );
		it("Menu language is 'Show _MENU_ entries' by default ", function () {
			$('#example').dataTable();
			expect($('#example').DataTable().settings()[0].oLanguage.sLengthMenu  === "Show _MENU_ entries").toBe(true);
		});
		it("_MENU_ macro is replaced by select menu in DOM", function () {
			expect($('select', $('#example').DataTable().settings()[0].aanFeatures.l[0]).length == 1).toBe(true);
		});

		it("A label input is used", function () {
			expect( $('label', $('#example').DataTable().settings()[0].aanFeatures.l[0]).length == 1 ).toBe(true);
		});
		it("Default is put into DOM", function () {
			var anChildren = $('label',$('#example').DataTable().settings()[0].aanFeatures.l[0])[0].childNodes;

			expect(bReturn = anChildren[0].nodeValue == "Show " && anChildren[2].nodeValue == " entries").toBe(true);
		});
		dt.html( 'basic' );
		it("Menu length can be defined - no _MENU_ macro", function () {
			$('#example').dataTable( {
				"language": {
					"lengthMenu": "unit test"
				}
			});
			expect($('#example').DataTable().settings()[0].oLanguage.sLengthMenu == "unit test").toBe(true);
		});
		it("Menu length language definition is in the dom", function () {
			expect($('label', $('#example').DataTable().settings()[0].aanFeatures.l[0]).text() == "unit test").toBe(true);
		});
		dt.html( 'basic' );
		it("Menu length language can be defined - with _MENU_ macro", function () {
			$('#example').dataTable( {
				"language": {
					"lengthMenu": "unit _MENU_ test"
				}
			});
			var anChildren = $('label',$('#example').DataTable().settings()[0].aanFeatures.l[0])[0].childNodes;
			expect(bReturn = anChildren[0].nodeValue == "unit " && anChildren[2].nodeValue == " test").toBe(true);
		});
		dt.html('basic');
		it("Only the _MENU_ macro", function () {
			$('#example').dataTable( {
				"language": {
					"lengthMenu": "_MENU_"
				}
			});
			var anChildren = $('#example').DataTable().settings()[0].aanFeatures.l[0].childNodes;
			expect(bReturn = anChildren.length == 1 && $('select', $('#example').DataTable().settings()[0].aanFeatures.l[0]).length == 1).toBe(true);
		});
	});
});