File: pageLength.js

package info (click to toggle)
datatables.js 1.10.19%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 6,348 kB
  • sloc: xml: 10,397; php: 4,448; sh: 521; makefile: 21
file content (46 lines) | stat: -rw-r--r-- 1,335 bytes parent folder | download
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
describe('pageLength Option', function() {
	dt.libs({
		js: ['jquery', 'datatables'],
		css: ['datatables']
	});

	describe('Check the defaults', function() {
		dt.html('basic');
		it('Default length is 10', function() {
			let table = $('#example').DataTable();
			expect($('#example tbody tr').length).toBe(10);
			expect($('#example_length select').val()).toBe('10');
			expect(table.page.info().length).toBe(10);
		});

		dt.html('basic');
		it('Set initial length to 25', function() {
			table = $('#example').DataTable({
				pageLength: 25
			});
			expect($('#example tbody tr').length).toBe(25);
			expect($('#example_length select').val()).toBe('25');
			expect(table.page.info().length).toBe(25);
		});

		dt.html('basic');
		it('Set initial length to 100', function() {
			table = $('#example').DataTable({
				pageLength: 100
			});
			expect($('#example tbody tr').length).toBe(57);
			expect($('#example_length select').val()).toBe('100');
			expect(table.page.info().length).toBe(100);
		});

		dt.html('basic');
		it('Set initial length to 23 (unknown select menu length)', function() {
			table = $('#example').DataTable({
				pageLength: 23
			});
			expect($('#example tbody tr').length).toBe(23);
			expect($('#example_length select').val()).toBe(null);
			expect(table.page.info().length).toBe(23);
		});
	});
});