File size: 1,047 Bytes
30c32c8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
const test = require('tap').test;
const MouseWheel = require('../../src/io/mouseWheel');
const Runtime = require('../../src/engine/runtime');

test('spec', t => {
    const rt = new Runtime();
    const mw = new MouseWheel(rt);

    t.type(mw, 'object');
    t.type(mw.postData, 'function');
    t.end();
});

test('blocks activated by scrolling', t => {
    let _startHatsArgs;
    const rt = {
        startHats: (...args) => {
            _startHatsArgs = args;
        }
    };
    const mw = new MouseWheel(rt);

    _startHatsArgs = null;
    mw.postData({
        deltaY: -1
    });
    t.strictEquals(_startHatsArgs[0], 'event_whenkeypressed');
    t.strictEquals(_startHatsArgs[1].KEY_OPTION, 'up arrow');

    _startHatsArgs = null;
    mw.postData({
        deltaY: +1
    });
    t.strictEquals(_startHatsArgs[0], 'event_whenkeypressed');
    t.strictEquals(_startHatsArgs[1].KEY_OPTION, 'down arrow');

    _startHatsArgs = null;
    mw.postData({
        deltaY: 0
    });
    t.strictEquals(_startHatsArgs, null);

    t.end();
});