Skip to content

Commit fce840e

Browse files
add test to cover modifyPlotProps and nested Layout within Section
1 parent 9f553c4 commit fce840e

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/lib/__tests__/nestedContainerConnections-test.js

+35
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,39 @@ describe('Plot Connection', () => {
125125
expect(type).toBe(EDITOR_ACTIONS.UPDATE_LAYOUT);
126126
expect(payload).toEqual({update: {width: 11}});
127127
});
128+
129+
it('can supply and modify plotProps with <Trace><Section><LayoutComp>', () => {
130+
const fixtureProps = fixtures.scatter({layout: {width: 10}});
131+
const TracePanel = connectTraceToPlot(Panel);
132+
const supplyLayoutPlotProps = (props, context) => {
133+
return unpackPlotProps(props, {
134+
...context,
135+
...getLayoutContext(context),
136+
});
137+
};
138+
139+
const MAXWIDTH = 1000;
140+
const LayoutWidth = connectLayoutToPlot(
141+
connectToContainer(Numeric, {
142+
supplyPlotProps: supplyLayoutPlotProps,
143+
modifyPlotProps: (props, context, plotProps) => {
144+
plotProps.max = MAXWIDTH;
145+
},
146+
})
147+
);
148+
149+
const wrapper = mount(
150+
<TestEditor {...{...fixtureProps}}>
151+
<TracePanel traceIndex={0}>
152+
<Section name="Canvas">
153+
<LayoutWidth traceIndex={0} label="Width" attr="width" />
154+
</Section>
155+
</TracePanel>
156+
</TestEditor>
157+
)
158+
.find('[attr="width"]')
159+
.find(NumericInput);
160+
161+
expect(wrapper.prop('max')).toBe(MAXWIDTH);
162+
});
128163
});

0 commit comments

Comments
 (0)