diff --git a/Sources/Testing/testMacro.js b/Sources/Testing/testMacro.js index 0e0f244ca10..99995152b5a 100644 --- a/Sources/Testing/testMacro.js +++ b/Sources/Testing/testMacro.js @@ -650,11 +650,51 @@ test('Macro methods keystore tests', (t) => { t.end(); }); +test('Macro methods normalizeWheel tests', (t) => { + const wheelEvent = { wheelDeltaX: 120 }; + + let normalizeWheelReturn = macro.normalizeWheel(wheelEvent); + t.equal( + normalizeWheelReturn.spinY, + -1, + 'spinY should be set when only wheelDeltaX is defined' + ); + t.equal( + normalizeWheelReturn.spinY, + normalizeWheelReturn.spinX, + 'spinY should equal spinX when only wheelDeltaX is defined' + ); + t.equal( + normalizeWheelReturn.pixelY, + -10, + 'pixelY should be set when only wheelDeltaX is defined' + ); + t.equal( + normalizeWheelReturn.pixelY, + normalizeWheelReturn.pixelX, + 'pixelY should equal pixelX when only wheelDeltaX is defined' + ); + + wheelEvent.wheelDeltaY = 240; + normalizeWheelReturn = macro.normalizeWheel(wheelEvent); + t.equal( + normalizeWheelReturn.spinY, + -2, + 'spinY should be set using wheelDeltaY when defined' + ); + t.equal( + normalizeWheelReturn.pixelY, + -20, + 'pixelY should be set using wheelDeltaY when defined' + ); + + t.end(); +}); + test('Macro debounce can be cancelled', (t) => { const func = () => { t.fail('Should not call cancelled debounce function'); }; - const debFunc = macro.debounce(func, 5); debFunc(); debFunc.cancel();