forked from refined-github/refined-github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhotkeys.test.ts
More file actions
34 lines (30 loc) · 705 Bytes
/
hotkeys.test.ts
File metadata and controls
34 lines (30 loc) · 705 Bytes
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
import {test, assert} from 'vitest';
import {
addHotkey,
} from './hotkey.js';
function testAddHotkey(existing: string | undefined, added: string, final: string): void {
const link = document.createElement('a');
if (existing) {
link.setAttribute('data-hotkey', existing);
}
addHotkey(link, added);
assert.equal(link.dataset.hotkey, final);
}
test('addHotkey if one is specified', testAddHotkey.bind(
undefined,
'T-REX',
'CHICKEN',
'T-REX,CHICKEN',
));
test('addHotkey if the same is already specified', testAddHotkey.bind(
undefined,
'CHICKEN',
'CHICKEN',
'CHICKEN',
));
test('addHotkey when none are specified', testAddHotkey.bind(
undefined,
undefined,
'CHICKEN',
'CHICKEN',
));