File: orderMulti.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 (96 lines) | stat: -rw-r--r-- 2,872 bytes parent folder | download | duplicates (4)
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
describe('orderMulti option', function() {
	dt.libs({
		js: ['jquery', 'datatables'],
		css: ['datatables']
	});

	describe('Check the defaults', function() {
		dt.html('basic');
		it('Enabled by default', function() {
			expect($.fn.dataTable.defaults.bSortMulti).toBe(true);
		});

		it('Verify enabled by default', function() {
			$('#example').dataTable();
			$('#example thead th:eq(2)').click();
			var clickEvent = $.Event('click');
			clickEvent.shiftKey = true;
			$('#example thead th:eq(3)').trigger(clickEvent);
			expect($('#example tbody tr:eq(0) td:eq(0)').text()).toBe('Cedric Kelly');
		});

		dt.html('basic');
		it('Setting true is the same as the default', function() {
			$('#example').dataTable({
				orderMulti: true
			});
			$('#example thead th:eq(2)').click();
			var clickEvent = $.Event('click');
			clickEvent.shiftKey = true;
			$('#example thead th:eq(3)').trigger(clickEvent);
			expect($('#example tbody tr:eq(0) td:eq(0)').html()).toBe('Cedric Kelly');
		});

		dt.html('basic');
		it('Can be disabled', function() {
			$('#example').dataTable({
				orderMulti: false
			});
			$('#example thead th:eq(2)').click();
			var clickEvent = $.Event('click');
			clickEvent.shiftKey = true;
			$('#example thead th:eq(3)').trigger(clickEvent);
			expect($('#example tbody tr:eq(0) td:eq(0)').html()).toBe('Tatyana Fitzpatrick');
		});

		dt.html('basic');
		it('Setting true is the same as the default', function() {
			$('#example').dataTable({
				orderMulti: true
			});
			$('#example thead th:eq(2)').click();
			var clickEvent = $.Event('click');
			clickEvent.shiftKey = true;
			$('#example thead th:eq(3)').trigger(clickEvent);
			expect($('#example tbody tr:eq(0) td:eq(0)').html()).toBe('Cedric Kelly');
		});
	});

	describe('Functional tests', function() {
		dt.html('basic');
		it('Can set multiple ordering at initialisation', function() {
			$('#example').dataTable({
				order: [[2, 'asc'], [1, 'asc']],
				orderMulti: false
			});
			expect($('#example tbody td:eq(0)').text()).toBe('Gavin Joyce');
		});

		dt.html('basic');
		it('Can set multiple ordering programmitically', function() {
			var table = $('#example').DataTable({
				orderMulti: false
			});

			table.order([[2, 'asc'], [1, 'asc']]).draw(false);
			expect($('#example tbody td:eq(0)').text()).toBe('Gavin Joyce');
		});

		dt.html('two_tables');
		it('When multiple tables all OK', function() {
			$('#example_one').DataTable({
				orderMulti: true
			});
			$('#example_two').DataTable({
				orderMulti: false
			});
			var clickEvent = $.Event('click');
			clickEvent.shiftKey = true;
			$('#example_one thead th:eq(1)').trigger(clickEvent);
			$('#example_two thead th:eq(1)').trigger(clickEvent);

			expect($('#example_one tbody td:eq(0)').text()).toBe('Airi Satou');
			expect($('#example_two tbody td:eq(0)').text()).toBe('Sydney');
		});
	});
});