module("wysihtml5.dom.getAsDom", { teardown: function() { var iframe; while (iframe = document.querySelector("iframe.wysihtml5-sandbox")) { iframe.parentNode.removeChild(iframe); } } }); test("Basic test", function() { var result; result = wysihtml5.dom.getAsDom('foo'); equal(result.nodeName, "DIV"); equal(result.ownerDocument, document); equal(result.firstChild.nodeName, "SPAN"); equal(result.childNodes.length , 1); equal(result.firstChild.innerHTML, "foo"); ok(!document.getElementById("get-in-dom-element-test")); result = wysihtml5.dom.getAsDom("1 2"); equal(result.childNodes.length, 3); result = wysihtml5.dom.getAsDom(document.createElement("div")); equal(result.innerHTML.toLowerCase(), "
"); }); test("HTML5 elements", function() { var result; result = wysihtml5.dom.getAsDom("
foo
"); equal(result.firstChild.nodeName.toLowerCase(), "article"); equal(result.firstChild.innerHTML.toLowerCase(), "foo"); result = wysihtml5.dom.getAsDom("foo"); equal(result.innerHTML.toLowerCase(), "foo"); }); asyncTest("Different document context", function() { expect(2); new wysihtml5.dom.Sandbox(function(sandbox) { var result; result = wysihtml5.dom.getAsDom("
hello
", sandbox.getDocument()); equal(result.firstChild.ownerDocument, sandbox.getDocument()); result = wysihtml5.dom.getAsDom("
hello
", sandbox.getDocument()); equal(result.innerHTML.toLowerCase(), "
hello
"); start(); }).insertInto(document.body); });