Skip to content

Commit

Permalink
Remove odd values of bubbled events
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed May 25, 2021
1 parent 01d0974 commit 05006a1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
15 changes: 11 additions & 4 deletions packages/e2e-tests/specs/performance/site-editor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,21 @@ describe( 'Site Editor Performance', () => {
keyUpEvents,
] = getTypingEventDurations( traceResults );

const _keyDownEvents = keyDownEvents.filter(
( v, ii ) => ii % 2 === 0
);
const _keyPressEvents = keyPressEvents.filter(
( v, ii ) => ii % 2 === 0
);

expect(
keyDownEvents.length === keyPressEvents.length &&
keyPressEvents.length === keyUpEvents.length
_keyDownEvents.length === _keyPressEvents.length &&
_keyPressEvents.length === keyUpEvents.length
).toBe( true );

for ( let j = 0; j < keyDownEvents.length; j++ ) {
for ( let j = 0; j < _keyDownEvents.length; j++ ) {
results.type.push(
keyDownEvents[ j ] + keyPressEvents[ j ] + keyUpEvents[ j ]
_keyDownEvents[ j ] + _keyPressEvents[ j ] + keyUpEvents[ j ]
);
}

Expand Down
12 changes: 4 additions & 8 deletions packages/e2e-tests/specs/performance/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,12 @@ function isEvent( item ) {
);
}

function isKeyDownEvent( item, index, array ) {
const isBubbled =
array[ index - 1 ]?.args?.data?.functionName === 'bubbleEvent';
return isEvent( item ) && item.args.data.type === 'keydown' && ! isBubbled;
function isKeyDownEvent( item ) {
return isEvent( item ) && item.args.data.type === 'keydown';
}

function isKeyPressEvent( item, index, array ) {
const isBubbled =
array[ index - 1 ]?.args?.data?.functionName === 'bubbleEvent';
return isEvent( item ) && item.args.data.type === 'keypress' && ! isBubbled;
function isKeyPressEvent( item ) {
return isEvent( item ) && item.args.data.type === 'keypress';
}

function isKeyUpEvent( item ) {
Expand Down

0 comments on commit 05006a1

Please sign in to comment.