/*global require, module*/
/*jslint vars:true*/
(function () {'use strict';

var jml = require('../jml'),
    testCase = require('nodeunit').testCase,
    DOMParser = require('xmldom').DOMParser,
    XMLSerializer = require('xmldom').XMLSerializer,
    jsdom = require('jsdom').jsdom;

var xml = new DOMParser().parseFromString('<div class="test">someContent</div>', 'text/html');
var divDOM = xml.documentElement; // This polyfill apparently mistakenly avoids putting the document into a full HTML document (with body)

var divJamilih = ['div', {'class': 'test', 'xmlns': 'http://www.w3.org/1999/xhtml'}, ['someContent']];

var document = jsdom('');
var window = document.parentWindow;

module.exports = testCase({

    // ============================================================================
    'element with text content': function(test) {
    // ============================================================================
        test.expect(1);
        var expected = divJamilih;
        var result = jml.toJML(divDOM);
        test.deepEqual(expected, result);
        test.done();
    },
    // ============================================================================
    'text node': function(test) {
    // ============================================================================
        test.expect(1);
        var expected = 'text node content';

        var result = jml.toJML(document.createTextNode(expected));
        test.deepEqual(expected, result);
        test.done();
    },
    // ============================================================================
    'document fragment': function (test) {
    // ============================================================================
        var expected = {'#': [divJamilih]};
        var frag = document.createDocumentFragment();
        frag.appendChild(divDOM.cloneNode(true));
        var result = jml.toJML(frag);
        test.deepEqual(expected, result);
        test.done();
    }
});

}());

@@ -1190,253 +1190,2878 @@
    '
-text node': function(test) %7B%0A    // ============================================================================%0A        test.expect(1);%0A        var expected = 'text node content';%0A%0A        var result = jml.toJML(document.createTextNode(expected
+attribute node': function(test) %7B%0A    // ============================================================================%0A        test.expect(2);%0A        var xlink = %5B'http://www.w3.org/1999/xlink', 'href', 'http://example.com'%5D;%0A%0A        var expected = %7B$attribute: xlink%7D;%0A        var att = document.createAttributeNS.apply(document, xlink.slice(0, -1));%0A        att.value = xlink.slice(-1);%0A%0A        var result = jml.toJML(att);%0A        test.deepEqual(expected, result);%0A        %0A        xlink%5B0%5D = null;%0A        expected = %7B$attribute: xlink%7D;%0A        att = document.createAttribute.apply(document, xlink.slice(1, -1));%0A        att.value = xlink.slice(-1);%0A%0A        result = jml.toJML(att);%0A        test.deepEqual(expected, result);%0A%0A        test.done();%0A    %7D,%0A    // ============================================================================%0A    'text node': function(test) %7B%0A    // ============================================================================%0A        test.expect(1);%0A        var expected = 'text node content';%0A%0A        var result = jml.toJML(document.createTextNode(expected));%0A        test.deepEqual(expected, result);%0A        test.done();%0A    %7D,%0A    // ============================================================================%0A    'CDATA section': function(test) %7B%0A    // ============================================================================%0A        test.expect(1);%0A        var content = 'CDATA %3C%3E&%5C'%22 content';%0A        var expected = %5B'!%5B', content%5D;%0A%0A        var result = jml.toJML(document.createCDATASection(content));%0A        test.deepEqual(expected, result);%0A        test.done();%0A    %7D,%0A    // ============================================================================%0A    'entity reference': function(test) %7B%0A    // ============================================================================%0A        test.expect(1);%0A        var expected = %5B'&', 'anEntity'%5D;%0A%0A        var result = jml.toJML(document.createEntityReference('anEntity'));%0A        test.deepEqual(expected, result);%0A        test.done();%0A    %7D,%0A    // ============================================================================%0A    'processing instruction': function(test) %7B%0A    // ============================================================================%0A        test.expect(1);%0A        var expected = %5B'?', 'aTarget', 'a processing instruction'%5D;%0A%0A        var result = jml.toJML(document.createProcessingInstruction('aTarget', 'a processing instruction'));%0A        test.deepEqual(expected, result);%0A        test.done();%0A    %7D,%0A    // ============================================================================%0A    'comment': function(test) %7B%0A    // ============================================================================%0A        test.expect(1);%0A        var expected = %5B'!', 'a comment'%5D;%0A%0A        var result = jml.toJML(document.createComment('a comment'
 ));%0A

Add tests for attribute node, cdata, entity reference, processing instruction, comment