From 4172eafba0799f23cb0ceee6de5d839d83531e8c Mon Sep 17 00:00:00 2001 From: Samuel Asensi Date: Sat, 22 Jun 2019 15:17:35 +0200 Subject: [PATCH] Add/unit test for color change propagation (#1675) Relates to #1672 --- test/tests/Style.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/tests/Style.js b/test/tests/Style.js index f930592b..8e22e56c 100644 --- a/test/tests/Style.js +++ b/test/tests/Style.js @@ -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.' + ); +});