summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authornobuti <buti@nobuti.com>2018-10-26 18:59:14 +0200
committernobuti <buti@nobuti.com>2018-10-26 18:59:14 +0200
commitf968b09a42fb586f71b847c8d54be90309b46c8b (patch)
tree0778aa38a50e387c3a552614554ed9a9655680fc /spec
parent973556a88de356e610a8bf26d1e22d5a92033769 (diff)
downloadsvg.js-f968b09a42fb586f71b847c8d54be90309b46c8b.tar.gz
svg.js-f968b09a42fb586f71b847c8d54be90309b46c8b.zip
Added some tests
Diffstat (limited to 'spec')
-rw-r--r--spec/spec/element.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/spec/element.js b/spec/spec/element.js
index 41f2af4..6a88f37 100644
--- a/spec/spec/element.js
+++ b/spec/spec/element.js
@@ -894,6 +894,44 @@ describe('Element', function() {
).toBeTruthy()
})
})
+ describe('with a modifier function', function() {
+ it('executes the modifier', function() {
+ var rect = draw.rect(100,100).id(null)
+ , result = rect.svg(function(instance) {
+ instance.radius(10)
+ })
+
+ expect(
+ result === '<rect width="100" height="100" rx="10" ry="10"></rect>'
+ || result === '<rect height="100" width="100" rx="10" ry="10"></rect>'
+ || result === '<rect xmlns="http://www.w3.org/2000/svg" width="100" height="100" rx="10" ry="10"></rect>'
+ ).toBeTruthy()
+ })
+
+ it("execute the modifier to replace the node", function() {
+ var rect = draw.rect(100,100).id(null)
+ , result = rect.svg(function(instance) {
+ var newInstance = new SVG.Circle()
+ return newInstance
+ })
+
+ expect(
+ result === '<circle></circle>'
+ || result === '<circle xmlns="http://www.w3.org/2000/svg"></circle>'
+ ).toBeTruthy()
+ })
+
+ it("doesn't execute the modifier if return false", function() {
+ var rect = draw.rect(100,100).id(null)
+ , result = rect.svg(function(instance) {
+ return false
+ })
+
+ expect(
+ result == null
+ ).toBeTruthy()
+ })
+ })
})
describe('writeDataToDom()', function() {