Add/unit test for color change propagation (#1675)

Relates to #1672
This commit is contained in:
Samuel Asensi 2019-06-22 15:17:35 +02:00 committed by Jürg Lehni
parent b485724f83
commit 4172eafba0

View file

@ -192,3 +192,30 @@ test('setting Group#fillColor and #strokeColor 2', function() {
// The second path still has its strokeColor set to red:
equals(secondPath.strokeColor, new Color('red'), 'secondPath.strokeColor');
});
test('Color change propagation (#1672)', function(assert) {
// We use this trick to take a snapshot of the current canvas content
// without any kind of side effect that `item.rasterize()` or other
// techniques would have.
function getDataURL() {
view.update();
return view.context.canvas.toDataURL();
}
var item = new Path.Circle({
center: view.center,
radius: 70,
fillColor: 'red'
});
var imageDataBefore = getDataURL();
// Change style property and check that change was detected.
item.fillColor.hue += 100;
var imageDataAfter = getDataURL();
// We are limited to check that both snapshots are different.
equals(
imageDataBefore !== imageDataAfter, true,
'Canvas content should change after a change of item.fillColor.'
);
});