File: row.add%28%29.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 (66 lines) | stat: -rw-r--r-- 2,219 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
// todo tests
// 1- Add row using array,object and node for data parameter
// 2- check only 1 param and that is data.

describe( "rows- row.add() (API)", function() {
	dt.libs( {
		js:  [ 'jquery', 'datatables' ],
		css: [ 'datatables' ]
	} );

	describe("Check the defaults", function () {
		dt.html( 'basic' );
		it("Exists and is a function", function () {
			var table = $('#example').DataTable();
			expect(typeof table.row.add).toBe('function');
		});
		dt.html( 'basic' );
		it("Returns API instance", function () {
			var table = $('#example').DataTable();
			expect(table.row.add(["Phill Johnson", "Accountant", "Edinburgh", 24, "2009/11/28", "$65,000" ]) instanceof $.fn.dataTable.Api).toBe(true);
		});
		dt.html( 'basic' );
		it("Add row- Array", function () {
			var array1 = ["Phill Johnson", "Accountant", "Edinburgh", 24, "2009/11/28", "$65,000" ];
			var table = $('#example').DataTable();
			table.row.add(array1);
			$('#example_filter input').val("Phill Johnson").keyup();
			expect($('#example tbody tr:eq(0) td:eq(0)').html() === "Phill Johnson").toBe(true);
		});
		dt.html( 'basic' );
		it("Add row- Object", function () {
			var table = $('#example').DataTable({
				columns: [
					{ data: "name" },
					{ data: "position" },
					{ data: "office" },
					{ data: "age" },
					{ data: "start_date" },
					{ data: "salary" }
				],
			});
			table.row.add( {
				"name":       "Phill Johnson",
				"position":   "Accountant",
				"office":     "Edinburgh",
				"age": "24",
				"start_date": "2011/04/25",
				"salary":     "$3,120"
			} ).draw();
			$('#example_filter input').val("Phill Johnson").keyup();
			expect($('#example tbody tr:eq(0) td:eq(0)').html() === "Phill Johnson").toBe(true);
		});
		// dt.html( 'basic' );
		// it("Add row- Node", function () {
		// 	var table = $('#example').DataTable();
		// 	var node = '<tr role="row" class="odd"><td class="sorting_1">Phill Johnson</td><td>Accountant</td><td>Tokyo</td><td>33</td><td>2008/11/28</td><td>$162,700</td></tr>';
		// 	table.row.add(node);
		// 	$('#example_filter input').val("Phill Johnson").keyup();
		// 	expect($('#example tbody tr:eq(0) td:eq(0)').html() === "Phill Johnson").toBe(true);
		//
		// });


	});

});