diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2017-03-05 14:14:31 +0100 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2017-03-05 14:14:31 +0100 |
commit | 901de657bdc832df1447b29648f27b83e7e4a910 (patch) | |
tree | 0199422d958974c196236822f53be93588307bb5 /spec | |
parent | 020627905e5244e18b29664e052a16356824bfe3 (diff) | |
download | svg.js-901de657bdc832df1447b29648f27b83e7e4a910.tar.gz svg.js-901de657bdc832df1447b29648f27b83e7e4a910.zip |
`dx()/dy()` now accepts percentage values, too (#524)
but only if the value on the element is already percentage
Diffstat (limited to 'spec')
-rw-r--r-- | spec/spec/sugar.js | 22 |
1 files changed, 20 insertions, 2 deletions
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) }) }) |