File: deferRender.js

package info (click to toggle)
datatables.js 1.10.13%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 6,232 kB
  • ctags: 1,329
  • sloc: xml: 10,249; php: 4,387; sh: 492; makefile: 21
file content (67 lines) | stat: -rw-r--r-- 2,235 bytes parent folder | download | duplicates (2)
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
59
60
61
62
63
64
65
66
67
describe( "deferRender option", function() {
	var table;
	dt.libs( {
		js:  [ 'jquery', 'datatables' ],
		css: [ 'datatables' ]
	} );
	it( 'Is disabled by default', function () {
		expect( $.fn.dataTable.defaults.bDeferRender ).toBe( false );
	} );
	dt.html( 'empty' );
	it( 'Load DataTable', function (done) {
		table = $('#example').DataTable( {
			ajax: '/base/test/data/data.txt',
			deferRender: true,
			columns: [
				{ data: "name" },
				{ data: "position" },
				{ data: "office" },
				{ data: "extn" },
				{ data: "start_date" },
				{ data: "salary" }
			],
			initComplete: function ( settings, json ) {
				done();
			}
		} );
	} );
	it( 'Only ten rows were created', function () {
		expect( table.rows().nodes().count() ).toBe( 10 );
	} );
	it( 'And only those cells were created', function () {
		expect( table.cells().nodes().count() ).toBe( 60 );
	} );
	it( 'On next page 10 more rows are created', function () {
		table.page( 'next' ).draw( false );
		expect( table.rows().nodes().count() ).toBe( 20 );
		expect( table.cells().nodes().count() ).toBe( 120 );
	} );
	it( 'Jumping back to first page, no more rows are created', function () {
		table.page( 'previous' ).draw( false );
		expect( table.rows().nodes().count() ).toBe( 20 );
		expect( table.cells().nodes().count() ).toBe( 120 );
	} );
	it( 'Jumping to last page will not render all rows', function () {
		table.page( 'last' ).draw( false );
		expect( table.rows().nodes().count() ).toBe( 27 );
		expect( table.cells().nodes().count() ).toBe( 162 );
	} );
	it( 'Jumping back to first page again doesn\'t create more', function () {
		table.page( 'first' ).draw( false );
		expect( table.rows().nodes().count() ).toBe( 27 );
		expect( table.cells().nodes().count() ).toBe( 162 );
	} );
	it( 'Filtering will create only those required', function () {
		table.search( 'm' ).draw();
		expect( table.rows().nodes().count() ).toBe( 31 );
		expect( table.cells().nodes().count() ).toBe( 186 );
	} );
	dt.html( 'basic' );
	it( 'Has no effect on DOM sourced table', function () {
		table = $('#example').DataTable( {
			deferRender: true
		} );
		expect( table.rows().nodes().count() ).toBe( 57 );
		expect( table.cells().nodes().count() ).toBe( 342 );
	} );
} );