summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2017-03-06 18:52:28 +0100
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2017-03-06 18:52:28 +0100
commit41b55427a71f85e444a8729a552b4db5aa9ac772 (patch)
treedbc1283dcf058c020151981c2754d9a4b9c76492 /spec
parent9ceaf63493ded5caa3e2eb89203d88c645b856b4 (diff)
downloadsvg.js-41b55427a71f85e444a8729a552b4db5aa9ac772.tar.gz
svg.js-41b55427a71f85e444a8729a552b4db5aa9ac772.zip
make flip working with both axis when no parameter / only offset is passed
Diffstat (limited to 'spec')
-rw-r--r--spec/spec/element.js12
-rw-r--r--spec/spec/sugar.js15
2 files changed, 23 insertions, 4 deletions
diff --git a/spec/spec/element.js b/spec/spec/element.js
index 378505f..e05f596 100644
--- a/spec/spec/element.js
+++ b/spec/spec/element.js
@@ -295,11 +295,11 @@ describe('Element', function() {
rect.transform({ a: 0.5, c: 0.5 }).transform(new SVG.Matrix({ e: 20, f: 20 }), true)
expect(rect.node.getAttribute('transform')).toBe('matrix(0.5,0,0.5,1,20,20)')
})
- it('flips the element', function() {
+ it('flips the element on x axis', function() {
rect.transform({ flip: 'x' })
expect(rect.node.getAttribute('transform')).toBe('matrix(-1,0,0,1,100,0)')
})
- it('flips the element with offset', function() {
+ it('flips the element on x axis with offset', function() {
rect.transform({ flip: 'x', offset: 20 })
expect(rect.node.getAttribute('transform')).toBe('matrix(-1,0,0,1,40,0)')
})
@@ -307,6 +307,14 @@ describe('Element', function() {
rect.transform({ flip: 'y', offset: 20 })
expect(rect.node.getAttribute('transform')).toBe('matrix(1,0,0,-1,0,40)')
})
+ it('flips the element on both axis with offset', function() {
+ rect.transform({ flip: 'both', offset: 20 })
+ expect(rect.node.getAttribute('transform')).toBe('matrix(-1,0,0,-1,40,40)')
+ })
+ it('flips the element on both axis', function() {
+ rect.transform({ flip: 'both' })
+ expect(rect.node.getAttribute('transform')).toBe('matrix(-1,0,0,-1,0,0)')
+ })
})
describe('untransform()', function() {
diff --git a/spec/spec/sugar.js b/spec/spec/sugar.js
index 0aef812..df43610 100644
--- a/spec/spec/sugar.js
+++ b/spec/spec/sugar.js
@@ -171,8 +171,19 @@ describe('Sugar', function() {
})
it('redirects to transform()', function() {
- rect.flip(1,2)
- expect(rect.transform).toHaveBeenCalledWith({ flip: 1, offset: 2 })
+ rect.flip('x',2)
+ expect(rect.transform).toHaveBeenCalledWith({ flip: 'x', offset: 2 })
+ })
+
+ it('sets flip to "both" when calling without anything', 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)
+ expect(rect.transform).toHaveBeenCalledWith({ flip: 5, offset: 5 })
})
})