File: formatNumber.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 (48 lines) | stat: -rw-r--r-- 1,224 bytes parent folder | download | duplicates (3)
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
describe('formatNumber Option', function() {
	dt.libs({
		js: ['jquery', 'datatables'],
		css: ['datatables']
	});

	describe('Check the arguments', function() {
		let args;
		let table;

		dt.html('basic');
		it('Default should not be true', function() {
			table = $('#example').DataTable();
			expect($.fn.dataTable.defaults.fnFormatNumber).not.toBe(true);
		});

		dt.html('basic');
		it('Count arguments', function() {
			table = $('#example').DataTable({
				formatNumber: function() {
					args = arguments;
					return true;
				}
			});
			expect(args.length).toBe(1);
		});
		it('First arg is the settings', function() {
			expect(typeof args[0]).toBe('number');
		});
	});

	describe('Functional tests', function() {
		let table;

		dt.html('basic');
		it('Ensure returned string is used in the info', function() {
			table = $('#example').DataTable({
				formatNumber: function(toFormat) {
					return toFormat.toString() + ' XXX';
				}
			});
			expect($('div.dataTables_info').text()).toBe('Showing 1 XXX to 10 XXX of 57 XXX entries');
		});
		it('Ensure returned string is used in the page length', function() {
			expect($('div.dataTables_length select option:eq(0)').text()).toBe('10 XXX');
		});
	});
});