uiRange.spec.js
1.23 KB
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
import Range from '../src/js/ui/tools/range';
import { defaultRotateRangeValus } from '../src/js/consts';
describe('Range', () => {
let range, input, slider;
beforeEach(() => {
input = document.createElement('input');
slider = document.createElement('div');
range = new Range(
{
slider,
input,
},
defaultRotateRangeValus
);
});
it('The value must be incremented by 1, when keyCode 38 is found in the event handler with changeInputWithArrow.', () => {
const ev = {
target: input,
keyCode: 38,
};
input.value = '3';
range.eventHandler.changeInputWithArrow(ev);
expect(range.value).toBe(4);
});
it('The value must be decremented by 1, when keyCode 40 is found in the event handler with changeInputWithArrow.', () => {
const ev = {
target: input,
keyCode: 40,
};
input.value = '3';
range.eventHandler.changeInputWithArrow(ev);
expect(range.value).toBe(2);
});
it('The `changeInput` event handler should filter out any invalid input values.', () => {
const ev = {
target: input,
keyCode: 83,
};
input.value = '-3!!6s0s';
range.eventHandler.changeInput(ev);
expect(range.value).toBe(-360);
});
});