Skip to content

Commit 44969dd

Browse files
update all mentions of on* hooks
1 parent b5c8b83 commit 44969dd

12 files changed

+69
-63
lines changed

src/components/containers/__tests__/AnnotationAccordion-test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ describe('<AnnotationAccordion>', () => {
2929

3030
it('can add annotations', () => {
3131
const fixture = fixtures.scatter();
32-
const onUpdateLayout = jest.fn();
32+
const beforeUpdateLayout = jest.fn();
3333
const editor = mount(
34-
<TestEditor {...{...fixture, onUpdateLayout}}>
34+
<TestEditor {...{...fixture, beforeUpdateLayout}}>
3535
<LayoutPanel name="Annotations">
3636
<AnnotationAccordion canAdd>
3737
<Numeric attr="textangle" />
@@ -42,17 +42,17 @@ describe('<AnnotationAccordion>', () => {
4242

4343
editor.find('button.js-add-annotation-button').simulate('click');
4444

45-
const payload = onUpdateLayout.mock.calls[0][0];
45+
const payload = beforeUpdateLayout.mock.calls[0][0];
4646
expect(payload.update).toEqual({'annotations[0]': {text: 'new text'}});
4747
});
4848

4949
it('can delete annotations', () => {
5050
const fixture = fixtures.scatter({
5151
layout: {annotations: [{text: 'hodor'}, {text: 'rodoh'}]},
5252
});
53-
const onDeleteAnnotation = jest.fn();
53+
const beforeDeleteAnnotation = jest.fn();
5454
const editor = mount(
55-
<TestEditor {...{...fixture, onDeleteAnnotation}}>
55+
<TestEditor {...{...fixture, beforeDeleteAnnotation}}>
5656
<LayoutPanel name="Annotations">
5757
<AnnotationAccordion canAdd>
5858
<Numeric attr="textangle" />
@@ -65,7 +65,7 @@ describe('<AnnotationAccordion>', () => {
6565
.at(0)
6666
.simulate('click');
6767

68-
const update = onDeleteAnnotation.mock.calls[0][0];
68+
const update = beforeDeleteAnnotation.mock.calls[0][0];
6969
expect(update.annotationIndex).toBe(0);
7070
});
7171
});

src/components/containers/__tests__/Fold-test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ describe('<Fold>', () => {
3232
});
3333

3434
it('calls deleteContainer when function present and canDelete is true', () => {
35-
const onDeleteTrace = jest.fn();
35+
const beforeDeleteTrace = jest.fn();
3636
mount(
37-
<TestEditor {...fixtures.scatter()} onDeleteTrace={onDeleteTrace}>
37+
<TestEditor {...fixtures.scatter()} beforeDeleteTrace={beforeDeleteTrace}>
3838
<Panel>
3939
<TraceFold traceIndex={0} canDelete={true} foldIndex={0}>
4040
<Numeric attr="opacity" />
@@ -45,7 +45,7 @@ describe('<Fold>', () => {
4545
.find('.js-fold__delete')
4646
.simulate('click');
4747

48-
const payload = onDeleteTrace.mock.calls[0][0];
48+
const payload = beforeDeleteTrace.mock.calls[0][0];
4949
expect(payload).toEqual({traceIndexes: [0]});
5050
});
5151
});

src/components/containers/__tests__/Layout-test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ Layouts.forEach(Layout => {
2828
});
2929

3030
it(`sends updates to gd._layout`, () => {
31-
const onUpdateLayout = jest.fn();
31+
const beforeUpdateLayout = jest.fn();
3232
const wrapper = mount(
3333
<Editor
34-
onUpdateLayout={onUpdateLayout}
34+
beforeUpdateLayout={beforeUpdateLayout}
3535
{...fixtures.scatter({layout: {width: 100}})}
3636
>
3737
<Panel>
@@ -46,7 +46,7 @@ Layouts.forEach(Layout => {
4646

4747
const widthUpdate = 200;
4848
wrapper.prop('onChange')(widthUpdate);
49-
const payload = onUpdateLayout.mock.calls[0][0];
49+
const payload = beforeUpdateLayout.mock.calls[0][0];
5050
expect(payload).toEqual({update: {width: widthUpdate}});
5151
});
5252
});

src/components/containers/__tests__/TraceAccordion-test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ describe('<TraceAccordion>', () => {
2222

2323
it('can add traces', () => {
2424
const fixture = fixtures.scatter();
25-
const onAddTrace = jest.fn();
25+
const beforeAddTrace = jest.fn();
2626
const editor = mount(
27-
<TestEditor {...{...fixture, onAddTrace}}>
27+
<TestEditor {...{...fixture, beforeAddTrace}}>
2828
<Panel>
2929
<TraceAccordion canAdd>
3030
<Numeric attr="textangle" />
@@ -35,14 +35,14 @@ describe('<TraceAccordion>', () => {
3535

3636
editor.find('button.js-add-trace-button').simulate('click');
3737

38-
expect(onAddTrace).toBeCalled();
38+
expect(beforeAddTrace).toBeCalled();
3939
});
4040

4141
it('can delete traces', () => {
4242
const fixture = fixtures.scatter({data: [{name: 'hodor'}]});
43-
const onDeleteTrace = jest.fn();
43+
const beforeDeleteTrace = jest.fn();
4444
const editor = mount(
45-
<TestEditor {...{...fixture, onDeleteTrace}}>
45+
<TestEditor {...{...fixture, beforeDeleteTrace}}>
4646
<Panel>
4747
<TraceAccordion canAdd>
4848
<Numeric attr="textangle" />
@@ -56,8 +56,8 @@ describe('<TraceAccordion>', () => {
5656
.at(0)
5757
.simulate('click');
5858

59-
expect(onDeleteTrace).toBeCalled();
60-
const update = onDeleteTrace.mock.calls[0][0];
59+
expect(beforeDeleteTrace).toBeCalled();
60+
const update = beforeDeleteTrace.mock.calls[0][0];
6161
expect(update.traceIndexes[0]).toBe(0);
6262
});
6363
});

src/components/fields/__tests__/AnnotationRef-test.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,44 +32,50 @@ describe('<AnnotationRef>', () => {
3232
});
3333

3434
it('sends update for a[x|y]ref attr on [x|y]ref change', () => {
35-
const onUpdateLayout = jest.fn();
35+
const beforeUpdateLayout = jest.fn();
3636
const fixtureProps = fixtures.scatter({
3737
layout: {annotations: [{text: 'thor', ayref: 'y'}]},
3838
});
39-
const drop = render({onUpdateLayout, ...fixtureProps}).find(DropdownWidget);
39+
const drop = render({beforeUpdateLayout, ...fixtureProps}).find(
40+
DropdownWidget
41+
);
4042

4143
drop.prop('onChange')('y2');
4244

43-
const {update} = onUpdateLayout.mock.calls[0][0];
45+
const {update} = beforeUpdateLayout.mock.calls[0][0];
4446
expect(update).toEqual({
4547
'annotations[0].ayref': 'y2',
4648
'annotations[0].yref': 'y2',
4749
});
4850
});
4951

5052
it('does not send update for a[x|y]ref attr on "paper" change', () => {
51-
const onUpdateLayout = jest.fn();
53+
const beforeUpdateLayout = jest.fn();
5254
const fixtureProps = fixtures.scatter({
5355
layout: {annotations: [{text: 'thor', ayref: 'y'}]},
5456
});
55-
const drop = render({onUpdateLayout, ...fixtureProps}).find(DropdownWidget);
57+
const drop = render({beforeUpdateLayout, ...fixtureProps}).find(
58+
DropdownWidget
59+
);
5660

5761
drop.prop('onChange')('paper');
58-
const {update} = onUpdateLayout.mock.calls[0][0];
62+
const {update} = beforeUpdateLayout.mock.calls[0][0];
5963
expect(update).toEqual({
6064
'annotations[0].yref': 'paper',
6165
});
6266
});
6367

6468
it('does not send update for a[x|y]ref when a[x|y]ref is pixel', () => {
65-
const onUpdateLayout = jest.fn();
69+
const beforeUpdateLayout = jest.fn();
6670
const fixtureProps = fixtures.scatter({
6771
layout: {annotations: [{text: 'thor', yref: 'y', ayref: 'pixel'}]},
6872
});
69-
const drop = render({onUpdateLayout, ...fixtureProps}).find(DropdownWidget);
73+
const drop = render({beforeUpdateLayout, ...fixtureProps}).find(
74+
DropdownWidget
75+
);
7076

7177
drop.prop('onChange')('y2');
72-
const {update} = onUpdateLayout.mock.calls[0][0];
78+
const {update} = beforeUpdateLayout.mock.calls[0][0];
7379
expect(update).toEqual({
7480
'annotations[0].yref': 'y2',
7581
});

src/components/fields/__tests__/DataSelector-test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ describe('DataSelector', () => {
3535
it('uses gd.data dataSrc value not fullValue when arrayOk', () => {});
3636

3737
it('calls updatePlot with srcAttr and data when present', () => {
38-
const onUpdateTraces = jest.fn();
39-
const wrapper = render({onUpdateTraces}).find(DropdownWidget);
40-
onUpdateTraces.mockClear();
38+
const beforeUpdateTraces = jest.fn();
39+
const wrapper = render({beforeUpdateTraces}).find(DropdownWidget);
40+
beforeUpdateTraces.mockClear();
4141
wrapper.prop('onChange')('y1');
42-
expect(onUpdateTraces.mock.calls[0][0]).toEqual({
42+
expect(beforeUpdateTraces.mock.calls[0][0]).toEqual({
4343
update: {xsrc: 'y1', x: [2, 3, 4]},
4444
traceIndexes: [0],
4545
});

src/components/fields/__tests__/TraceSelector-test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,10 @@ describe('TraceSelector', () => {
125125
});
126126

127127
it('updates type=scatter mode=lines when type=line', () => {
128-
const onUpdateTraces = jest.fn();
128+
const beforeUpdateTraces = jest.fn();
129129
const editorProps = {
130130
...fixtures.scatter({data: [{type: 'scatter', mode: 'markers'}]}),
131-
onUpdateTraces,
131+
beforeUpdateTraces,
132132
plotly,
133133
};
134134
const wrapper = mount(
@@ -142,7 +142,7 @@ describe('TraceSelector', () => {
142142
const innerDropdown = wrapper.find(Dropdown);
143143
innerDropdown.prop('onChange')('line');
144144

145-
const payload = onUpdateTraces.mock.calls[0][0];
145+
const payload = beforeUpdateTraces.mock.calls[0][0];
146146
expect(payload.update).toEqual({
147147
fill: 'none',
148148
mode: 'lines',
@@ -151,10 +151,10 @@ describe('TraceSelector', () => {
151151
});
152152

153153
it('updates type=scatter fill=tozeroy when type=area', () => {
154-
const onUpdateTraces = jest.fn();
154+
const beforeUpdateTraces = jest.fn();
155155
const editorProps = {
156156
...fixtures.scatter({data: [{type: 'scatter', mode: 'markers'}]}),
157-
onUpdateTraces,
157+
beforeUpdateTraces,
158158
plotly,
159159
};
160160
const wrapper = mount(
@@ -168,7 +168,7 @@ describe('TraceSelector', () => {
168168
const innerDropdown = wrapper.find(Dropdown);
169169
innerDropdown.prop('onChange')('area');
170170

171-
const payload = onUpdateTraces.mock.calls[0][0];
171+
const payload = beforeUpdateTraces.mock.calls[0][0];
172172
expect(payload.update).toEqual({fill: 'tozeroy', type: 'scatter'});
173173
});
174174
});

src/lib/__tests__/connectAnnotationToLayout-test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {connectLayoutToPlot, connectAnnotationToLayout} from '..';
66

77
describe('connectAnnotationToLayout', () => {
88
it('sends update to layout.annotation[index]', () => {
9-
const onUpdateLayout = jest.fn();
9+
const beforeUpdateLayout = jest.fn();
1010
const fixture = fixtures.scatter({
1111
layout: {annotations: [{text: 'hodor'}]},
1212
});
@@ -15,15 +15,15 @@ describe('connectAnnotationToLayout', () => {
1515
);
1616

1717
mount(
18-
<TestEditor {...{...fixture, onUpdateLayout}}>
18+
<TestEditor {...{...fixture, beforeUpdateLayout}}>
1919
<ConnectedNumeric annotationIndex={0} label="Angle" attr="textangle" />
2020
</TestEditor>
2121
)
2222
.find(NumericInput)
2323
.find('.js-numeric-increase')
2424
.simulate('click');
2525

26-
const payload = onUpdateLayout.mock.calls[0][0];
26+
const payload = beforeUpdateLayout.mock.calls[0][0];
2727
expect(payload.update).toEqual({'annotations[0].textangle': 1});
2828
});
2929
});

src/lib/__tests__/connectLayoutToPlot-test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ Layouts.forEach(Layout => {
3030
});
3131

3232
it(`sends updates to gd._layout`, () => {
33-
const onUpdateLayout = jest.fn();
33+
const beforeUpdateLayout = jest.fn();
3434
const wrapper = mount(
3535
<Editor
36-
onUpdateLayout={onUpdateLayout}
36+
beforeUpdateLayout={beforeUpdateLayout}
3737
{...fixtures.scatter({layout: {width: 100}})}
3838
>
3939
<Panel>
@@ -48,7 +48,7 @@ Layouts.forEach(Layout => {
4848

4949
const widthUpdate = 200;
5050
wrapper.prop('onChange')(widthUpdate);
51-
const payload = onUpdateLayout.mock.calls[0][0];
51+
const payload = beforeUpdateLayout.mock.calls[0][0];
5252
expect(payload).toEqual({update: {width: widthUpdate}});
5353
});
5454

src/lib/__tests__/connectTraceToPlot-test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ Traces.forEach(Trace => {
3232
});
3333

3434
it('sends updates to gd.data', () => {
35-
const onUpdateTraces = jest.fn();
35+
const beforeUpdateTraces = jest.fn();
3636
const wrapper = mount(
37-
<Editor onUpdateTraces={onUpdateTraces} {...fixtures.scatter()}>
37+
<Editor beforeUpdateTraces={beforeUpdateTraces} {...fixtures.scatter()}>
3838
<Panel>
3939
<Trace traceIndex={0} foldIndex={0}>
4040
<Numeric label="Marker Size" attr="marker.size" />
@@ -47,7 +47,7 @@ Traces.forEach(Trace => {
4747

4848
const sizeUpdate = 200;
4949
wrapper.prop('onChange')(sizeUpdate);
50-
const payload = onUpdateTraces.mock.calls[0][0];
50+
const payload = beforeUpdateTraces.mock.calls[0][0];
5151
expect(payload).toEqual({
5252
update: {'marker.size': sizeUpdate},
5353
traceIndexes: [0],

0 commit comments

Comments
 (0)