Skip to content

Commit 61a472e

Browse files
committed
Fix tests
1 parent 9cd0686 commit 61a472e

File tree

7 files changed

+23
-73
lines changed

7 files changed

+23
-73
lines changed

karma.conf.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ module.exports = function(karma) {
1919
// These settings deal with browser disconnects. We had seen test flakiness from Firefox
2020
// [Firefox 56.0.0 (Linux 0.0.0)]: Disconnected (1 times), because no message in 10000 ms.
2121
// https://github.com/jasmine/jasmine/issues/1327#issuecomment-332939551
22-
browserNoActivityTimeout: 60000,
2322
browserDisconnectTolerance: 3
2423
};
2524

src/controllers/controller.doughnut.js

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,14 @@ module.exports = function(Chart) {
229229
});
230230

231231
var model = arc._model;
232+
232233
// Resets the visual styles
233-
this.removeHoverStyle(arc);
234+
var custom = arc.custom || {};
235+
var valueOrDefault = helpers.valueAtIndexOrDefault;
236+
var elementOpts = this.chart.options.elements.arc;
237+
model.backgroundColor = custom.backgroundColor ? custom.backgroundColor : valueOrDefault(dataset.backgroundColor, index, elementOpts.backgroundColor);
238+
model.borderColor = custom.borderColor ? custom.borderColor : valueOrDefault(dataset.borderColor, index, elementOpts.borderColor);
239+
model.borderWidth = custom.borderWidth ? custom.borderWidth : valueOrDefault(dataset.borderWidth, index, elementOpts.borderWidth);
234240

235241
// Set correct angles if not resetting
236242
if (!reset || !animationOpts.animateRotate) {
@@ -246,19 +252,6 @@ module.exports = function(Chart) {
246252
arc.pivot();
247253
},
248254

249-
/* removeHoverStyle: function(element) {
250-
var elementOpts = this.chart.options.elements.arc;
251-
var dataset = this.chart.data.datasets[element._datasetIndex];
252-
var index = element._index;
253-
var custom = element.custom || {};
254-
var valueOrDefault = helpers.valueAtIndexOrDefault;
255-
var model = element._model;
256-
257-
model.backgroundColor = custom.backgroundColor ? custom.backgroundColor : valueOrDefault(dataset.backgroundColor, index, elementOpts.backgroundColor);
258-
model.borderColor = custom.borderColor ? custom.borderColor : valueOrDefault(dataset.borderColor, index, elementOpts.borderColor);
259-
model.borderWidth = custom.borderWidth ? custom.borderWidth : valueOrDefault(dataset.borderWidth, index, elementOpts.borderWidth);
260-
}, */
261-
262255
calculateTotal: function() {
263256
var dataset = this.getDataset();
264257
var meta = this.getMeta();

src/controllers/controller.line.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -313,18 +313,10 @@ module.exports = function(Chart) {
313313
radius: model.radius
314314
};
315315

316-
model.backgroundColor
317-
= custom.hoverBackgroundColor
318-
|| helpers.valueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.getHoverColor(model.backgroundColor));
319-
model.borderColor
320-
= custom.hoverBorderColor
321-
|| helpers.valueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.getHoverColor(model.borderColor));
322-
model.borderWidth
323-
= custom.hoverBorderWidth
324-
|| helpers.valueAtIndexOrDefault(dataset.pointHoverBorderWidth, index, model.borderWidth);
325-
model.radius
326-
= custom.hoverRadius
327-
|| helpers.valueAtIndexOrDefault(dataset.pointHoverRadius, index, this.chart.options.elements.point.hoverRadius);
316+
model.backgroundColor = custom.hoverBackgroundColor || helpers.valueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.getHoverColor(model.backgroundColor));
317+
model.borderColor = custom.hoverBorderColor || helpers.valueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.getHoverColor(model.borderColor));
318+
model.borderWidth = custom.hoverBorderWidth || helpers.valueAtIndexOrDefault(dataset.pointHoverBorderWidth, index, model.borderWidth);
319+
model.radius = custom.hoverRadius || helpers.valueAtIndexOrDefault(dataset.pointHoverRadius, index, this.chart.options.elements.point.hoverRadius);
328320
},
329321
});
330322
};

src/controllers/controller.polarArea.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -188,22 +188,16 @@ module.exports = function(Chart) {
188188
});
189189

190190
// Apply border and fill style
191-
me.removeHoverStyle(arc);
192-
193-
arc.pivot();
194-
},
195-
196-
removeHoverStyle: function(element) {
197191
var elementOpts = this.chart.options.elements.arc;
198-
var dataset = this.chart.data.datasets[element._datasetIndex];
199-
var index = element._index;
200-
var custom = element.custom || {};
192+
var custom = arc.custom || {};
201193
var valueOrDefault = helpers.valueAtIndexOrDefault;
202-
var model = element._model;
194+
var model = arc._model;
203195

204196
model.backgroundColor = custom.backgroundColor ? custom.backgroundColor : valueOrDefault(dataset.backgroundColor, index, elementOpts.backgroundColor);
205197
model.borderColor = custom.borderColor ? custom.borderColor : valueOrDefault(dataset.borderColor, index, elementOpts.borderColor);
206198
model.borderWidth = custom.borderWidth ? custom.borderWidth : valueOrDefault(dataset.borderWidth, index, elementOpts.borderWidth);
199+
200+
arc.pivot();
207201
},
208202

209203
countVisibleElements: function() {

src/controllers/controller.radar.js

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -153,22 +153,10 @@ module.exports = function(Chart) {
153153
radius: model.radius
154154
};
155155

156-
model.radius
157-
= custom.hoverRadius
158-
? custom.hoverRadius
159-
: helpers.valueAtIndexOrDefault(dataset.pointHoverRadius, index, this.chart.options.elements.point.hoverRadius);
160-
model.backgroundColor
161-
= custom.hoverBackgroundColor
162-
? custom.hoverBackgroundColor
163-
: helpers.valueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.getHoverColor(model.backgroundColor));
164-
model.borderColor
165-
= custom.hoverBorderColor
166-
? custom.hoverBorderColor
167-
: helpers.valueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.getHoverColor(model.borderColor));
168-
model.borderWidth
169-
= custom.hoverBorderWidth
170-
? custom.hoverBorderWidth
171-
: helpers.valueAtIndexOrDefault(dataset.pointHoverBorderWidth, index, model.borderWidth);
156+
model.radius = custom.hoverRadius ? custom.hoverRadius : helpers.valueAtIndexOrDefault(dataset.pointHoverRadius, index, this.chart.options.elements.point.hoverRadius);
157+
model.backgroundColor = custom.hoverBackgroundColor ? custom.hoverBackgroundColor : helpers.valueAtIndexOrDefault(dataset.pointHoverBackgroundColor, index, helpers.getHoverColor(model.backgroundColor));
158+
model.borderColor = custom.hoverBorderColor ? custom.hoverBorderColor : helpers.valueAtIndexOrDefault(dataset.pointHoverBorderColor, index, helpers.getHoverColor(model.borderColor));
159+
model.borderWidth = custom.hoverBorderWidth ? custom.hoverBorderWidth : helpers.valueAtIndexOrDefault(dataset.pointHoverBorderWidth, index, model.borderWidth);
172160
},
173161
});
174162
};

src/core/core.datasetController.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ module.exports = function(Chart) {
247247
var dataset = this.chart.data.datasets[element._datasetIndex];
248248
var index = element._index;
249249
var custom = element.custom || {};
250+
var valueOrDefault = helpers.valueAtIndexOrDefault;
250251
var getHoverColor = helpers.getHoverColor;
251252
var model = element._model;
252253

@@ -256,18 +257,9 @@ module.exports = function(Chart) {
256257
borderWidth: model.borderWidth
257258
};
258259

259-
model.backgroundColor
260-
= custom.hoverBackgroundColor
261-
? custom.hoverBackgroundColor
262-
: helpers.valueAtIndexOrDefault(dataset.hoverBackgroundColor, index, getHoverColor(model.backgroundColor));
263-
model.borderColor
264-
= custom.hoverBorderColor
265-
? custom.hoverBorderColor
266-
: helpers.valueAtIndexOrDefault(dataset.hoverBorderColor, index, getHoverColor(model.borderColor));
267-
model.borderWidth
268-
= custom.hoverBorderWidth
269-
? custom.hoverBorderWidth
270-
: helpers.valueAtIndexOrDefault(dataset.hoverBorderWidth, index, model.borderWidth);
260+
model.backgroundColor = custom.hoverBackgroundColor ? custom.hoverBackgroundColor : valueOrDefault(dataset.hoverBackgroundColor, index, getHoverColor(model.backgroundColor));
261+
model.borderColor = custom.hoverBorderColor ? custom.hoverBorderColor : valueOrDefault(dataset.hoverBorderColor, index, getHoverColor(model.borderColor));
262+
model.borderWidth = custom.hoverBorderWidth ? custom.hoverBorderWidth : valueOrDefault(dataset.hoverBorderWidth, index, model.borderWidth);
271263
},
272264

273265
/**

test/specs/controller.doughnut.tests.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,7 @@ describe('Chart.controllers.doughnut', function() {
357357
var arc = meta.data[0];
358358

359359
chart.update();
360-
//
361360
meta.controller.setHoverStyle(arc);
362-
//
363361
meta.controller.removeHoverStyle(arc);
364362
expect(arc._model.backgroundColor).toBe('rgb(255, 0, 0)');
365363
expect(arc._model.borderColor).toBe('rgb(0, 0, 255)');
@@ -370,9 +368,7 @@ describe('Chart.controllers.doughnut', function() {
370368
chart.data.datasets[0].borderColor = 'rgb(18, 18, 18)';
371369
chart.data.datasets[0].borderWidth = 1.56;
372370
chart.update();
373-
//
374371
meta.controller.setHoverStyle(arc);
375-
//
376372
meta.controller.removeHoverStyle(arc);
377373
expect(arc._model.backgroundColor).toBe('rgb(9, 9, 9)');
378374
expect(arc._model.borderColor).toBe('rgb(18, 18, 18)');
@@ -383,9 +379,7 @@ describe('Chart.controllers.doughnut', function() {
383379
chart.data.datasets[0].borderColor = ['rgb(18, 18, 18)'];
384380
chart.data.datasets[0].borderWidth = [0.1, 1.56];
385381
chart.update();
386-
//
387382
meta.controller.setHoverStyle(arc);
388-
//
389383
meta.controller.removeHoverStyle(arc);
390384
expect(arc._model.backgroundColor).toBe('rgb(255, 255, 255)');
391385
expect(arc._model.borderColor).toBe('rgb(18, 18, 18)');
@@ -399,9 +393,7 @@ describe('Chart.controllers.doughnut', function() {
399393
};
400394

401395
chart.update();
402-
//
403396
meta.controller.setHoverStyle(arc);
404-
//
405397
meta.controller.removeHoverStyle(arc);
406398
expect(arc._model.backgroundColor).toBe('rgb(7, 7, 7)');
407399
expect(arc._model.borderColor).toBe('rgb(17, 17, 17)');

0 commit comments

Comments
 (0)