Skip to content

Commit

Permalink
Make testTransitionComponent helper more resilient and future-proof
Browse files Browse the repository at this point in the history
  • Loading branch information
acelaya committed Jul 25, 2023
1 parent ad65b6d commit 416ebd2
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/components/test/common-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,12 @@ export function testSimpleComponent(Component) {
*/
export function testTransitionComponent(
Component,
{ componentName, createContent = createComponent, event = {} } = {}
{
componentName,
createContent = createComponent,
event = {},
elementSelector = '[ontransitionend]',
} = {}
) {
const displayName = componentName ?? Component.displayName ?? Component.name;

Expand All @@ -334,12 +339,12 @@ export function testTransitionComponent(
onTransitionEnd,
});

// Default to the main container as the `target` for the TransitionEvent,
// as that would be the actual behavior at runtime.
// If that's not desired, callers can still override it by providing
// event.target explicitly.
const container = wrapper.find('div');
const container = wrapper.find(elementSelector);
container.prop('ontransitionend')({
// Default to the main container as the `target` for the TransitionEvent,
// as that would be the actual behavior at runtime.
// If that's not desired, callers can still override it by providing
// event.target explicitly.
target: container.getDOMNode(),
...event,
});
Expand Down

0 comments on commit 416ebd2

Please sign in to comment.