Skip to content

Commit

Permalink
Remove animation-specific tests (as they can't be tested in jsdom)
Browse files Browse the repository at this point in the history
  • Loading branch information
ciampo committed Dec 13, 2023
1 parent 92acce9 commit f84568c
Showing 1 changed file with 0 additions and 64 deletions.
64 changes: 0 additions & 64 deletions packages/components/src/navigator/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -769,68 +769,4 @@ describe( 'Navigator', () => {
).toHaveFocus();
} );
} );

describe( 'animation', () => {
it( 'should not animate the initial screen', async () => {
const onHomeAnimationStartSpy = jest.fn();

render(
<NavigatorProvider initialPath="/">
<NavigatorScreen
path="/"
onAnimationStart={ onHomeAnimationStartSpy }
>
<CustomNavigatorButton path="/child">
To child
</CustomNavigatorButton>
</NavigatorScreen>
</NavigatorProvider>
);

expect( onHomeAnimationStartSpy ).not.toHaveBeenCalled();
} );

it( 'should animate all other screens (including the initial screen when navigating back)', async () => {
const user = userEvent.setup();

const onHomeAnimationStartSpy = jest.fn();
const onChildAnimationStartSpy = jest.fn();

render(
<NavigatorProvider initialPath="/">
<NavigatorScreen
path="/"
onAnimationStart={ onHomeAnimationStartSpy }
>
<CustomNavigatorButton path="/child">
To child
</CustomNavigatorButton>
</NavigatorScreen>
<NavigatorScreen
path="/child"
onAnimationStart={ onChildAnimationStartSpy }
>
<CustomNavigatorBackButton>
Back to home
</CustomNavigatorBackButton>
</NavigatorScreen>
</NavigatorProvider>
);

expect( onHomeAnimationStartSpy ).not.toHaveBeenCalled();
expect( onChildAnimationStartSpy ).not.toHaveBeenCalled();

await user.click(
screen.getByRole( 'button', { name: 'To child' } )
);
expect( onChildAnimationStartSpy ).toHaveBeenCalledTimes( 1 );
expect( onHomeAnimationStartSpy ).not.toHaveBeenCalled();

await user.click(
screen.getByRole( 'button', { name: 'Back to home' } )
);
expect( onChildAnimationStartSpy ).toHaveBeenCalledTimes( 1 );
expect( onHomeAnimationStartSpy ).toHaveBeenCalledTimes( 1 );
} );
} );
} );

0 comments on commit f84568c

Please sign in to comment.