Merge pull request #920 from towerofnix/scroll-detection

Scroll wheel detection for "when key (up/down) pressed" blocks
This commit is contained in:
Chris Willis-Ford 2018-02-16 12:21:27 -08:00 committed by GitHub
commit 8e1719b716
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 75 additions and 1 deletions

View file

@ -0,0 +1,44 @@
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();
});