File: tabIndex.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 (30 lines) | stat: -rw-r--r-- 1,011 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
describe('tabIndex Option', function() {
	dt.libs({
		js: ['jquery', 'datatables'],
		css: ['datatables']
	});

	/*****
	 * Note these tests are limited - JS cannot issue key presses as that would pose a huge security problem:
	 * https://stackoverflow.com/questions/596481/is-it-possible-to-simulate-key-press-events-programmatically/42755803
	 * It's possible with Selenium, but they're not being used in unit tests. I tried checking jQuery's next() method
	 * to see if that would act as a cheat, but no luck unfortunately. So, bit rubbish, all we can do is confirm
	 * the option.
	 *****/
	describe('Check the defaults', function() {
		dt.html('basic');
		it('Test using default value', function() {
			let table = $('#example').DataTable({
				tabIndex: 0
			});
			expect(table.settings()[0].iTabIndex).toBe(0);
		});
		dt.html('basic');
		it('Test using -1', function() {
			let table = $('#example').DataTable({
				tabIndex: -1
			});
			expect(table.settings()[0].iTabIndex).toBe(-1);
		});
	});
});