Skip to content

Commit d553150

Browse files
authored
Add Area animation tests (#5967)
1 parent 53822e3 commit d553150

File tree

7 files changed

+575
-26
lines changed

7 files changed

+575
-26
lines changed

storybook/stories/Examples/AreaChart.stories.tsx

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
import { CategoricalChartProps } from '../API/props/ChartProps';
1818
import { getStoryArgsFromArgsTypesObject } from '../API/props/utils';
1919
import { RechartsHookInspector } from '../../storybook-addon-recharts/RechartsHookInspector';
20+
import { ManualAnimations } from '../../storybook-addon-recharts/ManualAnimations';
2021

2122
export default {
2223
component: AreaChart,
@@ -607,16 +608,18 @@ export const WithChangingDataKeyAndAnimations = {
607608
Hidden
608609
</label>
609610
</form>
610-
<ResponsiveContainer width="100%">
611-
<ComposedChart {...args}>
612-
<Legend />
613-
<XAxis dataKey="name" />
614-
<YAxis />
615-
<Area dataKey={dataKey} label={{ fill: 'green' }} dot />
616-
<Tooltip />
617-
<RechartsHookInspector rechartsInspectorEnabled={context.rechartsInspectorEnabled} />
618-
</ComposedChart>
619-
</ResponsiveContainer>
611+
<ManualAnimations isEnabled={context.rechartsInspectorEnabled}>
612+
<ResponsiveContainer width="100%">
613+
<ComposedChart {...args}>
614+
<Legend />
615+
<XAxis dataKey="name" />
616+
<YAxis />
617+
<Area dataKey={dataKey} label={{ fill: 'green' }} dot />
618+
<Tooltip />
619+
<RechartsHookInspector rechartsInspectorEnabled={context.rechartsInspectorEnabled} />
620+
</ComposedChart>
621+
</ResponsiveContainer>
622+
</ManualAnimations>
620623
</>
621624
);
622625
},

storybook/storybook-addon-recharts/ManualAnimations.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ export function ManualAnimations({ isEnabled, children }: Props) {
3535
}
3636
return (
3737
<AnimationManagerContext.Provider value={animationManager}>
38-
{/* div to force vertical stacking */}
39-
<div>
38+
{/* div to force vertical stacking. Comes with some basic styling so that it allows ResponsiveContainer to render */}
39+
<div style={{ width: '100%', height: '100%', display: 'flex', flexDirection: 'column' }}>
4040
{children}
4141
<form>
4242
<h3>Manual Animations</h3>

test/animation/MockAbstractAnimationManager.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ export abstract class MockAbstractAnimationManager implements AnimationManager {
5151
await this.timeoutController.triggerNextTimeout(now);
5252
}
5353

54+
public isAnimating(): boolean {
55+
return this.queue !== null && this.queue.length > 0;
56+
}
57+
5458
protected queue: ReactSmoothQueue | null = null;
5559

5660
protected readonly timeoutController: MockTimeoutController = new MockTimeoutController();

0 commit comments

Comments
 (0)