diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-11-24 11:17:13 +0100 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-11-24 11:17:13 +0100 |
commit | 858f19e9f8b9ba26eee8d3aeb8ba8b5b5058472b (patch) | |
tree | fa0c355901bf93e6dc418a759f06ab7899e0452a /spec | |
parent | 8555e13b252f07f8079b08c0b29f4399d389b1e0 (diff) | |
download | svg.js-858f19e9f8b9ba26eee8d3aeb8ba8b5b5058472b.tar.gz svg.js-858f19e9f8b9ba26eee8d3aeb8ba8b5b5058472b.zip |
Get rid of HTMLNode and Bare in favor of Dom
- words() and element() added to Dom
- svg() now returns the _parent_ of the imported element, when outerHTML is true (which means an element gets replaces)
Diffstat (limited to 'spec')
-rw-r--r-- | spec/spec/adopter.js | 6 | ||||
-rw-r--r-- | spec/spec/bare.js | 41 | ||||
-rw-r--r-- | spec/spec/element.js | 35 | ||||
-rw-r--r-- | spec/spec/svg.js | 8 |
4 files changed, 41 insertions, 49 deletions
diff --git a/spec/spec/adopter.js b/spec/spec/adopter.js index 38d55f4..6beb63b 100644 --- a/spec/spec/adopter.js +++ b/spec/spec/adopter.js @@ -71,11 +71,9 @@ describe('Adopter', function() { }) describe('with node that has no matching svg.js class', function() { - it('wraps the node in the base SVG.Element class', function() { + it('wraps the node in the Dom class', function() { var desc = SVG('#inlineSVG').find('desc')[0] - expect(desc instanceof SVG.Element).toBeTruthy() + expect(desc instanceof SVG.Dom).toBeTruthy() }) }) - - }) diff --git a/spec/spec/bare.js b/spec/spec/bare.js deleted file mode 100644 index 5601a37..0000000 --- a/spec/spec/bare.js +++ /dev/null @@ -1,41 +0,0 @@ -describe('Bare', function() { - - describe('element()', function() { - var element - - beforeEach(function() { - element = draw.element('rect') - }) - - it('creates an instance of SVG.Bare', function() { - expect(element instanceof SVG.Bare).toBeTruthy() - }) - it('creates element in called parent', function() { - expect(element.parent()).toBe(draw) - }) - // it('inherits from given parent', function() { - // expect(draw.element('g', SVG.Container).rect).toBeTruthy() - // expect(draw.element('g', SVG.Container).group).toBeTruthy() - // }) - }) - - describe('words()', function() { - it('inserts plain text in a node', function() { - var element = draw.element('title').words('These are some words.').id(null) - var result = element.svg() - expect( - result == '<title>These are some words.</title>' - || result == '<title xmlns="http://www.w3.org/2000/svg">These are some words.</title>' - ).toBe(true) - }) - it('removes all nodes before adding words', function() { - var element = draw.element('title').words('These are some words.').id(null) - element.words('These are some words.') - var result = element.svg() - expect( - result == '<title>These are some words.</title>' - || result == '<title xmlns="http://www.w3.org/2000/svg">These are some words.</title>' - ).toBe(true) - }) - }) -}) diff --git a/spec/spec/element.js b/spec/spec/element.js index 4845f03..6fb1ff4 100644 --- a/spec/spec/element.js +++ b/spec/spec/element.js @@ -1045,4 +1045,39 @@ describe('Element', function() { })) }) }) + + describe('words()', function() { + it('inserts plain text in a node', function() { + var element = draw.element('title').words('These are some words.').id(null) + var result = element.svg() + expect( + result == '<title>These are some words.</title>' + || result == '<title xmlns="http://www.w3.org/2000/svg">These are some words.</title>' + ).toBe(true) + }) + it('removes all nodes before adding words', function() { + var element = draw.element('title').words('These are some words.').id(null) + element.words('These are some words.') + var result = element.svg() + expect( + result == '<title>These are some words.</title>' + || result == '<title xmlns="http://www.w3.org/2000/svg">These are some words.</title>' + ).toBe(true) + }) + }) + + describe('element()', function() { + var element + + beforeEach(function() { + element = draw.element('rect') + }) + + it('creates an instance of Dom', function() { + expect(element instanceof SVG.Dom).toBeTruthy() + }) + it('creates element in called parent', function() { + expect(element.parent()).toBe(draw) + }) + }) }) diff --git a/spec/spec/svg.js b/spec/spec/svg.js index acdd686..a3e33b5 100644 --- a/spec/spec/svg.js +++ b/spec/spec/svg.js @@ -23,15 +23,15 @@ describe('SVG', function() { expect(SVG().node.nodeName).toBe('svg') }) - it('creates an instanceof SVG.HtmlNode with html node', function() { + it('creates an instanceof SVG.Dom with html node', function() { var el = SVG(wrapperHTML) - expect(el instanceof SVG.HtmlNode).toBe(true) + expect(el instanceof SVG.Dom).toBe(true) expect(el.node).toBe(wrapperHTML) }) - it('creates new SVG.HtmlNode when called with css selector pointing to html node', function() { + it('creates new SVG.Dom when called with css selector pointing to html node', function() { var el = SVG('#testDiv') - expect(el instanceof SVG.HtmlNode).toBe(true) + expect(el instanceof SVG.Dom).toBe(true) expect(el.node).toBe(wrapperHTML) }) |