From 858f19e9f8b9ba26eee8d3aeb8ba8b5b5058472b Mon Sep 17 00:00:00 2001 From: Ulrich-Matthias Schäfer Date: Sat, 24 Nov 2018 11:17:13 +0100 Subject: 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) --- spec/spec/adopter.js | 6 ++---- spec/spec/bare.js | 41 ----------------------------------------- spec/spec/element.js | 35 +++++++++++++++++++++++++++++++++++ spec/spec/svg.js | 8 ++++---- 4 files changed, 41 insertions(+), 49 deletions(-) delete mode 100644 spec/spec/bare.js (limited to 'spec') 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 == 'These are some words.' - || result == 'These are some words.' - ).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 == 'These are some words.' - || result == 'These are some words.' - ).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 == 'These are some words.' + || result == 'These are some words.' + ).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 == 'These are some words.' + || result == 'These are some words.' + ).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) }) -- cgit v1.2.3