Skip to content

Commit 0bda0a3

Browse files
committed
Fix tests
1 parent 9cd0686 commit 0bda0a3

9 files changed

+25
-80
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: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,6 @@ describe('Chart.controllers.doughnut', function() {
294294
var meta = chart.getDatasetMeta(0);
295295
var arc = meta.data[0];
296296

297-
298297
meta.controller.setHoverStyle(arc);
299298
expect(arc._model.backgroundColor).toBe('rgb(230, 0, 0)');
300299
expect(arc._model.borderColor).toBe('rgb(0, 0, 230)');
@@ -357,9 +356,7 @@ describe('Chart.controllers.doughnut', function() {
357356
var arc = meta.data[0];
358357

359358
chart.update();
360-
//
361359
meta.controller.setHoverStyle(arc);
362-
//
363360
meta.controller.removeHoverStyle(arc);
364361
expect(arc._model.backgroundColor).toBe('rgb(255, 0, 0)');
365362
expect(arc._model.borderColor).toBe('rgb(0, 0, 255)');
@@ -369,10 +366,9 @@ describe('Chart.controllers.doughnut', function() {
369366
chart.data.datasets[0].backgroundColor = 'rgb(9, 9, 9)';
370367
chart.data.datasets[0].borderColor = 'rgb(18, 18, 18)';
371368
chart.data.datasets[0].borderWidth = 1.56;
369+
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)');
@@ -382,10 +378,9 @@ describe('Chart.controllers.doughnut', function() {
382378
chart.data.datasets[0].backgroundColor = ['rgb(255, 255, 255)', 'rgb(9, 9, 9)'];
383379
chart.data.datasets[0].borderColor = ['rgb(18, 18, 18)'];
384380
chart.data.datasets[0].borderWidth = [0.1, 1.56];
381+
385382
chart.update();
386-
//
387383
meta.controller.setHoverStyle(arc);
388-
//
389384
meta.controller.removeHoverStyle(arc);
390385
expect(arc._model.backgroundColor).toBe('rgb(255, 255, 255)');
391386
expect(arc._model.borderColor).toBe('rgb(18, 18, 18)');
@@ -399,9 +394,7 @@ describe('Chart.controllers.doughnut', function() {
399394
};
400395

401396
chart.update();
402-
//
403397
meta.controller.setHoverStyle(arc);
404-
//
405398
meta.controller.removeHoverStyle(arc);
406399
expect(arc._model.backgroundColor).toBe('rgb(7, 7, 7)');
407400
expect(arc._model.borderColor).toBe('rgb(17, 17, 17)');

test/specs/controller.line.tests.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,6 @@ describe('Chart.controllers.line', function() {
704704

705705
meta.controller.removeHoverStyle(point);
706706
chart.update();
707-
708707
expect(point._model.backgroundColor).toBe('rgb(45, 46, 47)');
709708
expect(point._model.borderColor).toBe('rgb(50, 51, 52)');
710709
expect(point._model.borderWidth).toBe(10.1);
@@ -718,7 +717,6 @@ describe('Chart.controllers.line', function() {
718717

719718
meta.controller.removeHoverStyle(point);
720719
chart.update();
721-
722720
expect(point._model.backgroundColor).toBe('rgb(77, 79, 81)');
723721
expect(point._model.borderColor).toBe('rgb(123, 125, 127)');
724722
expect(point._model.borderWidth).toBe(2.1);
@@ -731,7 +729,6 @@ describe('Chart.controllers.line', function() {
731729

732730
meta.controller.removeHoverStyle(point);
733731
chart.update();
734-
735732
expect(point._model.backgroundColor).toBe('rgb(77, 79, 81)');
736733
expect(point._model.borderColor).toBe('rgb(123, 125, 127)');
737734
expect(point._model.borderWidth).toBe(2.1);
@@ -747,7 +744,6 @@ describe('Chart.controllers.line', function() {
747744

748745
meta.controller.removeHoverStyle(point);
749746
chart.update();
750-
751747
expect(point._model.backgroundColor).toBe('rgb(0, 0, 0)');
752748
expect(point._model.borderColor).toBe('rgb(10, 10, 10)');
753749
expect(point._model.borderWidth).toBe(5.5);

test/specs/controller.polarArea.tests.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,14 +332,12 @@ describe('Chart.controllers.polarArea', function() {
332332

333333
meta.controller.setHoverStyle(arc);
334334
chart.update();
335-
336335
expect(arc._model.backgroundColor).toBe('rgb(45, 46, 47)');
337336
expect(arc._model.borderColor).toBe('rgb(50, 51, 52)');
338337
expect(arc._model.borderWidth).toBe(10.1);
339338

340339
meta.controller.removeHoverStyle(arc);
341340
chart.update();
342-
343341
expect(arc._model.backgroundColor).toBe('rgb(45, 46, 47)');
344342
expect(arc._model.borderColor).toBe('rgb(50, 51, 52)');
345343
expect(arc._model.borderWidth).toBe(10.1);

0 commit comments

Comments
 (0)