File: columns_className.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 (76 lines) | stat: -rw-r--r-- 2,749 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
68
69
70
71
72
73
74
75
76
describe( "columns.className option", function() {
	dt.libs( {
		js:  [ 'jquery', 'datatables' ],
		css: [ 'datatables' ]
	} );

	describe("Check the defaults", function () {

		dt.html( 'basic' );
		it("By default the test class hasn't been applied to the column", function () {
			$('#example').dataTable( {
			});
			expect($('#example tbody tr:eq(0) td:eq(2)').hasClass('unittest')).not.toBe(true) ;
		});
		dt.html( 'basic' );
		it("Sorting on Column 1 is uneffected", function () {
			$('#example').dataTable( {
				"columns": [
			    null,
			    null,
			    { "className": "unittest" },
			    null,
			    null,
				null
			  ]
			});
			expect($('#example tbody tr:eq(0) td:eq(2)').hasClass('unittest')).toBe(true);
		});

		it("Add a class to a single column- third row", function () {
			expect($('#example tbody tr:eq(2) td:eq(2)').hasClass('unittest')).toBe(true);
		});
		it("Add a class to a single column- last row", function () {
			expect($('#example tbody tr:eq(9) td:eq(2)').hasClass('unittest')).toBe(true);
		});
		it("Add a class to a sinlge column- has not applied to other coluns- 1st", function () {
			expect($('#example tbody tr:eq(3) td:eq(0)').hasClass('unittest')).toBe(false);
		});
		it("Add a class to a sinlge column- has not applied to other coluns- 5th", function () {
			expect($('#example tbody tr:eq(3) td:eq(4)').hasClass('unittest')).toBe(false);
		});
		it("Add a class to a single column- seventh row- second page", function () {
			$('#example_next').click();
			expect($('#example tbody tr:eq(6) td:eq(2)').hasClass('unittest')).toBe(true);
		});
		it("Add a class to a single column- has not applied to header", function () {
			expect($('#example thead tr:eq(0) th:eq(4)').hasClass('unittest')).toBe(false);
		});
		it("Add a class to a single column- has not applied to footer", function () {
			expect($('#example tfoot tr:eq(0) th:eq(4)').hasClass('unittest')).toBe(false);
		});

		dt.html( 'basic' );
		it("Class defined for multiple columns- first row", function () {
			$('#example').dataTable( {
				"columns": [
			    { "className": "unittest1" },
			    null,
			    { "className": "unittest2" },
			    null,
			    null,
				null
			  ]
			});
			expect($('#example tbody tr:eq(0) td:eq(0)').hasClass('unittest1') && $('#example tbody tr:eq(0) td:eq(2)').hasClass('unittest2')).toBe(true);
		});

		it("Class defined for multiple columns- has not applied to other columns- 5th 1", function () {
			expect($('#example tobody tr:eq(0) td:eq(4)').hasClass('unittest1')).toBe(false);
		});
		it("Class defined for multiple columns- has not applied to other columns- 5th 3", function () {
			expect($('#example tobody tr:eq(6) td:eq(4)').hasClass('unittest2')).toBe(false);
		});
	});

});