aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2017-04-25 13:22:58 +0200
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2017-04-25 13:22:58 +0200
commit4455a789b65027a53f9f1e610de14570a8f06891 (patch)
treeb66fcfa042c5fdc06ca271a934b2d33a008a1c61 /spec
parent966084444a436180ebe4078501ede11bc609c5cb (diff)
downloadsvg.js-fix-basetag-bug.tar.gz
svg.js-fix-basetag-bug.zip
added tests, make replacement for all elements using hreffix-basetag-bug
Diffstat (limited to 'spec')
-rw-r--r--spec/spec/element.js40
-rw-r--r--spec/spec/use.js2
2 files changed, 41 insertions, 1 deletions
diff --git a/spec/spec/element.js b/spec/spec/element.js
index 18343d2..2bcc531 100644
--- a/spec/spec/element.js
+++ b/spec/spec/element.js
@@ -861,6 +861,46 @@ describe('Element', function() {
|| toBeTested === '<circle xmlns="http://www.w3.org/2000/svg" r="50" cx="50" cy="50" fill="#ff0066"></circle>'
).toBeTruthy()
})
+ it('correctly removes the current location from urls on export', function() {
+ var rect2, rect1 = draw.rect(100,100).clipWith(rect2 = draw.rect(100,100))
+ expect(rect1.attr('clip-path')).toBe('url(' + window.location + '#' + rect2.parent().id() + ')')
+
+ var doc = document.createElement('svg')
+ doc.innerHTML = rect1.svg()
+
+ expect(doc.firstChild.getAttribute('clip-path')).toBe('url(#' + rect2.parent().id() + ')')
+
+ rect1.attr('clip-path', 'url(http://someUrl.com/with/path/and#Hash)')
+
+ doc.innerHTML = rect1.svg()
+ expect(doc.firstChild.getAttribute('clip-path')).toBe('url(http://someUrl.com/with/path/and#Hash)')
+ })
+ it('correctly removes the current location from href on export', function() {
+ var link = draw.link('#somewhere')
+ expect(link.to()).toBe(window.location + '#somewhere')
+
+ var doc = document.createElement('svg')
+ doc.innerHTML = link.svg()
+ expect(doc.firstChild.getAttribute('xlink:href')).toBe('#somewhere')
+
+ link.to('http://someUrl.com/with/path/and#Hash')
+ doc.innerHTML = link.svg()
+ expect(doc.firstChild.getAttribute('xlink:href')).toBe('http://someUrl.com/with/path/and#Hash')
+ })
+ it('correctly adds the current location to urls on import', function() {
+ draw.svg('<rect width="100" height="100" clip-path="url(#something)" id="someId">')
+ expect(SVG.get('someId').attr('clip-path')).toBe('url(' + window.location + '#something)')
+
+ draw.clear().svg('<rect width="100" height="100" clip-path="url(http://someUrl.com/with/path/and#Hash)" id="someId">')
+ expect(SVG.get('someId').attr('clip-path')).toBe('url(http://someUrl.com/with/path/and#Hash)')
+ })
+ it('correctly adds the current location to href on import', function() {
+ draw.svg('<a href="#something" id="someId">')
+ expect(SVG.get('someId').attr('href')).toBe(window.location + '#something')
+
+ draw.clear().svg('<a href="http://someUrl.com/with/path/and#Hash" id="someId">')
+ expect(SVG.get('someId').attr('href')).toBe('http://someUrl.com/with/path/and#Hash')
+ })
})
describe('with raw svg given', function() {
it('imports a full svg document', function() {
diff --git a/spec/spec/use.js b/spec/spec/use.js
index 0de5b39..b173f4f 100644
--- a/spec/spec/use.js
+++ b/spec/spec/use.js
@@ -14,7 +14,7 @@ describe('Use', function() {
})
it('sets the target element id to its href attribute', function() {
- expect(use.node.getAttributeNS(SVG.xlink, 'href')).toBe('#' + rect)
+ expect(use.node.getAttributeNS(SVG.xlink, 'href')).toBe(window.location + '#' + rect)
})
it('adopts the geometry of the target element', function() {