4 ], function(chai, smartxml) {
9 var expect = chai.expect;
12 var getDocumentFromXML = function(xml) {
13 return smartxml.documentFromXML(xml);
16 var elementNodeFromParams = function(params) {
17 return smartxml.elementNodeFromXML('<' + params.tag + '></' + params.tag + '>');
20 var elementNodeFromXML = function(xml) {
21 return smartxml.elementNodeFromXML(xml);
25 describe.only('smartxml', function() {
27 describe('Basic Document properties', function() {
28 it('exposes its root element', function() {
29 var doc = getDocumentFromXML('<div></div>');
30 expect(doc.root.getTagName()).to.equal('div');
34 describe('Basic ElementNode properties', function() {
35 it('exposes node contents', function() {
36 var node = elementNodeFromXML('<node>Some<node>text</node>is here</node>'),
37 contents = node.contents();
39 expect(contents).to.have.length(3);
40 expect(contents[0].nodeType).to.equal(Node.TEXT_NODE, 'text node 1');
41 expect(contents[1].nodeType).to.equal(Node.ELEMENT_NODE, 'element node 1');
42 expect(contents[2].nodeType).to.equal(Node.TEXT_NODE, 'text node 2');
46 describe('Manipulations', function() {
48 it('appende element node to another element node', function() {
49 var node1 = elementNodeFromParams({tag: 'div'}),
50 node2 = elementNodeFromParams({tag: 'a'});
52 expect(node1.contents()[0].sameNode(node2)).to.be.true;