From f968b09a42fb586f71b847c8d54be90309b46c8b Mon Sep 17 00:00:00 2001 From: nobuti Date: Fri, 26 Oct 2018 18:59:14 +0200 Subject: [PATCH] Added some tests --- spec/spec/element.js | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) 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 === '' + || result === '' + || result === '' + ).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 === '' + || result === '' + ).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() { -- 2.39.5