Skip to content

Commit

Permalink
test(macro): add test for normalizeWheel spinY and pixelY
Browse files Browse the repository at this point in the history
Test that spinY and pixelY are set correctly in normalizeWheel when only wheelDeltaX is defined and
when wheelDeltaY is also defined

re #2834
  • Loading branch information
DevinAPorro committed Dec 22, 2023
1 parent 7f82d54 commit 91b0681
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion Sources/Testing/testMacro.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 91b0681

Please sign in to comment.