describe('XML', function () {

  var XML = require('../XML'), libxmljs = require("libxmljs");

  describe('#parse', function () {
    it('parses the xml string into an object', function () {
      var xml = '<?xml version="1.0" encoding="UTF-8"?><items><item><value>Item 1</value></item><item><value>Item 2</value></item><item><value>Item 3</value></item></items>';
      var obj = XML.parse(xml);
      verifyParsedObject(obj);
    });

    it('parses the libxml object into a POJO', function () {
      var xml = '<?xml version="1.0" encoding="UTF-8"?><items><item><value>Item 1</value></item><item><value>Item 2</value></item><item><value>Item 3</value></item></items>';
      var obj = XML.parse(libxmljs.parseXml(xml));
      verifyParsedObject(obj);
    });

    it('parses attributes into properties', function () {
      var xml = '<?xml version="1.0" encoding="UTF-8"?><items><item value="Item 1"/><item value="Item 2"/><item value="Item 3"/></items>';
      var obj = XML.parse(xml);
      verifyParsedObject(obj);
    });

    // TODO: handles array of text nodes
    it.skip('parses arrays of text nodes', function () {
      var xml = '<?xml version="1.0" encoding="UTF-8"?><items><item>Item 1</item><item>Item 2</item><item>Item 3</item></items>';
      var obj = XML.parse(xml);
      obj.items.should.exist;
      obj.items.item.should.be.an.instanceOf(Array);
      obj.items.item.length.should.equal(3);
      obj.items.item[0].should.equal('Item 1');
    });

    function verifyParsedObject (obj) {
      obj.items.should.exist;
      obj.items.item.should.be.an.instanceOf(Array);
      obj.items.item.length.should.equal(3);
      obj.items.item[0].value.should.equal('Item 1');
    }
  });

  describe('#stringify', function () {
    it('stringifies the object into an xml string', function () {
      var obj = {"items":{"item":[{"value":"Item 1"},{"value":"Item 2"},{"value":"Item 3"}]}};
      var xml = '<items><item><value>Item 1</value></item><item><value>Item 2</value></item><item><value>Item 3</value></item></items>';
      XML.stringify(obj).should.equal(xml);
    });
  });

});

@@ -2096,16 +2096,296 @@
     %7D);%0A
+%0A    it('stringifies simple arrays into an xml string', function () %7B%0A      var obj = %7B%22items%22:%7B%22item%22:%5B%22Item 1%22,%22Item 2%22,%22Item 3%22%5D%7D%7D;%0A      var xml = '%3Citems%3E%3Citem%3EItem 1%3C/item%3E%3Citem%3EItem 2%3C/item%3E%3Citem%3EItem 3%3C/item%3E%3C/items%3E';%0A      XML.stringify(obj).should.equal(xml);%0A    %7D);%0A%0A
   %7D);%0A%0A%7D

Add test to stringily array of text nodes