Skip to content

Commit

Permalink
Unit test, linted and adapted to pass in Safari.
Browse files Browse the repository at this point in the history
  • Loading branch information
TorsteinHonsi committed Jul 26, 2016
1 parent 44deb74 commit 0bb91ed
Showing 1 changed file with 73 additions and 72 deletions.
145 changes: 73 additions & 72 deletions samples/unit-tests/drilldown/activedatalabelstyle/demo.js
Original file line number Diff line number Diff line change
@@ -1,86 +1,87 @@
QUnit.test('activeDataLabelStyle', function (assert) {
var getDataLabelFill = function (point) {
return point.dataLabel.element.childNodes[0].style.fill;
};
var chart = Highcharts.chart('container', {
chart: {
type: 'column'
},
plotOptions: {
series: {
dataLabels: {
enabled: true,
inside: true
}
}
},
series: [{
data: [{
drilldown: 'fruits',
y: 20,
color: '#000000'
}]
}],
drilldown: {
series: [{
id: 'fruits',
data: [2]
}]
}
})
series = series = chart.series[0]
point = series.points[0];
assert.strictEqual(
getDataLabelFill(point),
'rgb(13, 35, 58)',
function getDataLabelFill(point) {
return point.dataLabel.element.childNodes[0].style.fill;
}
var chart = Highcharts.chart('container', {
chart: {
type: 'column'
},
plotOptions: {
series: {
dataLabels: {
enabled: true,
inside: true
}
}
},
series: [{
data: [{
drilldown: 'fruits',
y: 20,
color: '#000000'
}]
}],
drilldown: {
series: [{
id: 'fruits',
data: [2]
}]
}
}),

series = chart.series[0],
point = series.points[0];


assert.ok(
getDataLabelFill(point) === 'rgb(13, 35, 58)' || getDataLabelFill(point) === '#0d233a',
'activeDataLabelStyle.color default to rgb(13, 35, 58)'
);

// @notice Would have been nice with a chart.update.
// @notice activeDataLabelStyle should probably be possible to override on a series or point level.
chart.destroy();
chart = Highcharts.chart('container', {
chart: {
type: 'column'
},
plotOptions: {
series: {
dataLabels: {
enabled: true,
inside: true
}
}
},
series: [{
data: [{
drilldown: 'fruits',
y: 20,
color: '#000000'
}]
}],
drilldown: {
activeDataLabelStyle: {
color: 'contrast'
},
series: [{
id: 'fruits',
data: [2]
}]
}
}),
series = chart.series[0],
point = series.points[0];
assert.strictEqual(
getDataLabelFill(point),
'rgb(255, 255, 255)',
chart = Highcharts.chart('container', {
chart: {
type: 'column'
},
plotOptions: {
series: {
dataLabels: {
enabled: true,
inside: true
}
}
},
series: [{
data: [{
drilldown: 'fruits',
y: 20,
color: '#000000'
}]
}],
drilldown: {
activeDataLabelStyle: {
color: 'contrast'
},
series: [{
id: 'fruits',
data: [2]
}]
}
});
series = chart.series[0];
point = series.points[0];

assert.ok(
getDataLabelFill(point) === 'rgb(255, 255, 255)' || getDataLabelFill(point) === '#ffffff',
'activeDataLabelStyle.color contrast to black'
);
point.update({
color: '#FFFFFF'
color: '#FFFFFF'
});
assert.strictEqual(
getDataLabelFill(point),
'rgb(0, 0, 0)',
assert.ok(
getDataLabelFill(point) === 'rgb(0, 0, 0)' || getDataLabelFill(point) === '#000000',
'activeDataLabelStyle.color contrast to white'
);
});

0 comments on commit 0bb91ed

Please sign in to comment.