From 901de657bdc832df1447b29648f27b83e7e4a910 Mon Sep 17 00:00:00 2001 From: Ulrich-Matthias Schäfer Date: Sun, 5 Mar 2017 14:14:31 +0100 Subject: `dx()/dy()` now accepts percentage values, too (#524) but only if the value on the element is already percentage --- spec/spec/sugar.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'spec') diff --git a/spec/spec/sugar.js b/spec/spec/sugar.js index 2b9aa4c..0aef812 100644 --- a/spec/spec/sugar.js +++ b/spec/spec/sugar.js @@ -237,8 +237,26 @@ describe('Sugar', function() { it('redirects to x() / y() with adding the current value', function() { rect.dx(5) rect.dy(5) - expect(rect.x).toHaveBeenCalledWith(5, true) - expect(rect.y).toHaveBeenCalledWith(5, true) + expect(rect.x).toHaveBeenCalledWith(jasmine.objectContaining(new SVG.Number('5')), true) + expect(rect.y).toHaveBeenCalledWith(jasmine.objectContaining(new SVG.Number('5')), true) + }) + + it('allows to add a percentage value', function() { + rect.move('5%', '5%') + + rect.dx('5%') + rect.dy('5%') + + expect(rect.x).toHaveBeenCalledWith(jasmine.objectContaining(new SVG.Number('10%')), true) + expect(rect.y).toHaveBeenCalledWith(jasmine.objectContaining(new SVG.Number('10%')), true) + }) + + it('allows to add a percentage value when no x/y is set', function() { + rect.dx('5%') + rect.dy('5%') + + expect(rect.x).toHaveBeenCalledWith(jasmine.objectContaining(new SVG.Number('5%')), true) + expect(rect.y).toHaveBeenCalledWith(jasmine.objectContaining(new SVG.Number('5%')), true) }) }) -- cgit v1.2.3