Skip to content

Commit 80eab02

Browse files
committed
prettier v2 + jest v26
1 parent 0ef1fca commit 80eab02

File tree

3 files changed

+31
-31
lines changed

3 files changed

+31
-31
lines changed

src/__mocks__/plotly.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,35 @@ const state = {};
44
const ASYNC_DELAY = 1;
55

66
export default {
7-
plot: jest.fn(gd => {
7+
plot: jest.fn((gd) => {
88
state.gd = gd;
99
setTimeout(() => {
1010
state.gd.emit('plotly_afterplot');
1111
}, ASYNC_DELAY);
1212
}),
13-
newPlot: jest.fn(gd => {
13+
newPlot: jest.fn((gd) => {
1414
state.gd = gd;
1515
EventEmitter(state.gd); // eslint-disable-line new-cap
1616

1717
setTimeout(() => {
1818
state.gd.emit('plotly_afterplot');
1919
}, ASYNC_DELAY);
2020
}),
21-
react: jest.fn(gd => {
21+
react: jest.fn((gd) => {
2222
state.gd = gd;
2323
EventEmitter(state.gd); // eslint-disable-line new-cap
2424

2525
setTimeout(() => {
2626
state.gd.emit('plotly_afterplot');
2727
}, ASYNC_DELAY);
2828
}),
29-
relayout: jest.fn(gd => {
29+
relayout: jest.fn((gd) => {
3030
state.gd = gd;
3131
setTimeout(() => {
3232
state.gd.emit('plotly_relayout');
3333
}, ASYNC_DELAY);
3434
}),
35-
restyle: jest.fn(gd => {
35+
restyle: jest.fn((gd) => {
3636
state.gd = gd;
3737
setTimeout(() => {
3838
state.gd.emit('plotly_restyle');

src/__tests__/react-plotly.test.js

+21-21
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('<Plotly/>', () => {
3333

3434
describe('with mocked plotly.js', () => {
3535
beforeEach(() => {
36-
Plotly = require.requireMock('../__mocks__/plotly.js').default;
36+
Plotly = jest.requireMock('../__mocks__/plotly.js').default;
3737
PlotComponent = createComponent(Plotly);
3838

3939
// Override the parent element size:
@@ -43,19 +43,19 @@ describe('<Plotly/>', () => {
4343
});
4444
});
4545

46-
describe('initialization', function() {
47-
test('calls Plotly.react on instantiation', done => {
46+
describe('initialization', function () {
47+
test('calls Plotly.react on instantiation', (done) => {
4848
createPlot({})
4949
.then(() => {
5050
expect(Plotly.react).toHaveBeenCalled();
5151
})
52-
.catch(err => {
52+
.catch((err) => {
5353
done.fail(err);
5454
})
5555
.then(done);
5656
});
5757

58-
test('passes data', done => {
58+
test('passes data', (done) => {
5959
createPlot({
6060
data: [{x: [1, 2, 3]}],
6161
layout: {title: 'foo'},
@@ -66,11 +66,11 @@ describe('<Plotly/>', () => {
6666
layout: {title: 'foo'},
6767
});
6868
})
69-
.catch(err => done.fail(err))
69+
.catch((err) => done.fail(err))
7070
.then(done);
7171
});
7272

73-
test('accepts width and height', done => {
73+
test('accepts width and height', (done) => {
7474
createPlot({
7575
layout: {width: 320, height: 240},
7676
})
@@ -79,13 +79,13 @@ describe('<Plotly/>', () => {
7979
layout: {width: 320, height: 240},
8080
});
8181
})
82-
.catch(err => done.fail(err))
82+
.catch((err) => done.fail(err))
8383
.then(done);
8484
});
8585
});
8686

8787
describe('plot updates', () => {
88-
test('updates data', done => {
88+
test('updates data', (done) => {
8989
createPlot({
9090
layout: {width: 123, height: 456},
9191
onUpdate: once(() => {
@@ -96,13 +96,13 @@ describe('<Plotly/>', () => {
9696
done();
9797
}),
9898
})
99-
.then(plot => {
99+
.then((plot) => {
100100
plot.setProps({data: [{x: [1, 2, 3]}]});
101101
})
102-
.catch(err => done.fail(err));
102+
.catch((err) => done.fail(err));
103103
});
104104

105-
test('updates data when revision is defined but not changed', done => {
105+
test('updates data when revision is defined but not changed', (done) => {
106106
createPlot({
107107
revision: 1,
108108
layout: {width: 123, height: 456},
@@ -114,13 +114,13 @@ describe('<Plotly/>', () => {
114114
done();
115115
}),
116116
})
117-
.then(plot => {
117+
.then((plot) => {
118118
plot.setProps({revision: 1, data: [{x: [1, 2, 3]}]});
119119
})
120-
.catch(err => done.fail(err));
120+
.catch((err) => done.fail(err));
121121
});
122122

123-
test('sets the title', done => {
123+
test('sets the title', (done) => {
124124
createPlot({
125125
onUpdate: once(() => {
126126
expectPlotlyAPICall(Plotly.react, {
@@ -129,13 +129,13 @@ describe('<Plotly/>', () => {
129129
done();
130130
}),
131131
})
132-
.then(plot => {
132+
.then((plot) => {
133133
plot.setProps({layout: {title: 'test test'}});
134134
})
135-
.catch(err => done.fail(err));
135+
.catch((err) => done.fail(err));
136136
});
137137

138-
test('revision counter', done => {
138+
test('revision counter', (done) => {
139139
var callCnt = 0;
140140
createPlot({
141141
revision: 0,
@@ -153,15 +153,15 @@ describe('<Plotly/>', () => {
153153
}
154154
},
155155
})
156-
.then(plot => {
156+
.then((plot) => {
157157
// Update with and without revision bumps:
158158
/* eslint-disable no-magic-numbers */
159159
setTimeout(() => plot.setProps({layout: {title: 'test test'}}), 10);
160160
setTimeout(() => plot.setProps({revision: 1, layout: {title: 'test test'}}), 20);
161161
setTimeout(() => plot.setProps({revision: 1, layout: {title: 'test test'}}), 30);
162162
setTimeout(() => plot.setProps({revision: 2, layout: {title: 'test test'}}), 40);
163163
})
164-
.catch(err => done.fail(err));
164+
.catch((err) => done.fail(err));
165165
});
166166
});
167167

@@ -170,7 +170,7 @@ describe('<Plotly/>', () => {
170170
const onRelayout = () => {};
171171

172172
createPlot({onRelayout}).then((plot) => {
173-
const { handlers } = plot.instance();
173+
const {handlers} = plot.instance();
174174

175175
expect(plot.prop('onRelayout')).toBe(onRelayout);
176176
expect(handlers.Relayout).toBe(onRelayout);

src/factory.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export default function plotComponentFactory(Plotly) {
9494
this.attachUpdateEvents();
9595
}
9696
})
97-
.catch(err => {
97+
.catch((err) => {
9898
if (this.props.onError) {
9999
this.props.onError(err);
100100
}
@@ -152,7 +152,7 @@ export default function plotComponentFactory(Plotly) {
152152
return;
153153
}
154154

155-
updateEvents.forEach(updateEvent => {
155+
updateEvents.forEach((updateEvent) => {
156156
this.el.on(updateEvent, this.handleUpdate);
157157
});
158158
}
@@ -162,7 +162,7 @@ export default function plotComponentFactory(Plotly) {
162162
return;
163163
}
164164

165-
updateEvents.forEach(updateEvent => {
165+
updateEvents.forEach((updateEvent) => {
166166
this.el.removeListener(updateEvent, this.handleUpdate);
167167
});
168168
}
@@ -207,7 +207,7 @@ export default function plotComponentFactory(Plotly) {
207207

208208
// Attach and remove event handlers as they're added or removed from props:
209209
syncEventHandlers() {
210-
eventNames.forEach(eventName => {
210+
eventNames.forEach((eventName) => {
211211
const prop = this.props['on' + eventName];
212212
const handler = this.handlers[eventName];
213213
const hasHandler = Boolean(handler);
@@ -268,7 +268,7 @@ export default function plotComponentFactory(Plotly) {
268268
divId: PropTypes.string,
269269
};
270270

271-
eventNames.forEach(eventName => {
271+
eventNames.forEach((eventName) => {
272272
PlotlyComponent.propTypes['on' + eventName] = PropTypes.func;
273273
});
274274

0 commit comments

Comments
 (0)