diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2017-03-08 19:34:22 +0100 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2017-03-08 19:34:22 +0100 |
commit | 5587dd76de4d17038111e713d135e8a0a4f17453 (patch) | |
tree | e34c7b3ca2404b7401a5b832fac1490419a3c928 /spec | |
parent | 1f7a0ac6b903eb90ef8468aa2b2bd95d5df43c34 (diff) | |
download | svg.js-5587dd76de4d17038111e713d135e8a0a4f17453.tar.gz svg.js-5587dd76de4d17038111e713d135e8a0a4f17453.zip |
add ability to use `font()` method like `attr()` method (#620)
Diffstat (limited to 'spec')
-rw-r--r-- | spec/spec/sugar.js | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/spec/spec/sugar.js b/spec/spec/sugar.js index df43610..d550886 100644 --- a/spec/spec/sugar.js +++ b/spec/spec/sugar.js @@ -179,7 +179,7 @@ describe('Sugar', function() { rect.flip() expect(rect.transform).toHaveBeenCalledWith({ flip: 'both', offset: undefined }) }) - + // this works because only x and y are valid flip values. Evereything else flips on both axis it('sets flip to number and offset to number when called with offset only', function() { rect.flip(5) @@ -251,21 +251,21 @@ describe('Sugar', function() { 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) }) @@ -343,6 +343,16 @@ describe('Sugar', function() { expect(text.attr).toHaveBeenCalledWith('foo', 'bar') expect(text.attr).toHaveBeenCalledWith('bar', 'baz') }) + + it('sets key value pair when called with 2 parameters', function() { + text.font('size', 20) + expect(text.attr).toHaveBeenCalledWith('font-size', 20) + }) + + it('gets value if called with one parameter', function() { + text.font('size') + expect(text.attr).toHaveBeenCalledWith('font-size', undefined) + }) }) }) |