Skip to content

Commit bd15ca9

Browse files
author
Matt Fehskens
committed
Added correct name of remove handler method
- Added test for checking that a handler was added
1 parent 8dd14f3 commit bd15ca9

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/__tests__/react-plotly.test.js

+15
Original file line numberDiff line numberDiff line change
@@ -164,5 +164,20 @@ describe('<Plotly/>', () => {
164164
.catch(err => done.fail(err));
165165
});
166166
});
167+
168+
describe('manging event handlers', () => {
169+
test('should add an event handler when one does not already exist', (done) => {
170+
const onRelayout = () => {};
171+
172+
createPlot({onRelayout}).then((plot) => {
173+
const { handlers } = plot.instance();
174+
175+
expect(plot.prop('onRelayout')).toBe(onRelayout);
176+
expect(handlers.Relayout).toBe(onRelayout);
177+
178+
done();
179+
});
180+
});
181+
});
167182
});
168183
});

src/factory.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,10 @@ export default function plotComponentFactory(Plotly) {
214214
this.addEventHandler(eventName, prop);
215215
} else if (!prop && hasHandler) {
216216
// Needs to be removed:
217-
this.removeHandler(eventName);
217+
this.removeEventHandler(eventName);
218218
} else if (prop && hasHandler && prop !== handler) {
219219
// replace the handler
220-
this.removeHandler(eventName);
220+
this.removeEventHandler(eventName);
221221
this.addEventHandler(eventName, prop);
222222
}
223223
});

0 commit comments

Comments
 (0)