From e44a7e37b6c7b5961adaffc62b9042b8d442938e Mon Sep 17 00:00:00 2001 From: mensonge Date: Thu, 13 Nov 2008 09:49:11 +0000 Subject: New feature: basic Ajax suggestion for tags and implementation of Dojo toolkit git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@151 b3834d28-1941-0410-a4f8-b48e95affb8f --- includes/js/dojox/data/tests/dom.js | 133 ++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 includes/js/dojox/data/tests/dom.js (limited to 'includes/js/dojox/data/tests/dom.js') diff --git a/includes/js/dojox/data/tests/dom.js b/includes/js/dojox/data/tests/dom.js new file mode 100644 index 0000000..a6eb621 --- /dev/null +++ b/includes/js/dojox/data/tests/dom.js @@ -0,0 +1,133 @@ +if(!dojo._hasResource["dojox.data.tests.dom"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.data.tests.dom"] = true; +dojo.provide("dojox.data.tests.dom"); +dojo.require("dojox.data.dom"); + +tests.register("dojox.data.tests.dom", + [ + function testCreateDocument(t){ + var document = dojox.data.dom.createDocument(); + t.assertTrue(document !== null); + }, + function testCreateDocumentFromText(t){ + var simpleXml = ""; + var document = dojox.data.dom.createDocument(simpleXml, "text/xml"); + + var parent = document.firstChild; + t.assertTrue(parent !== null); + t.assertTrue(parent.tagName === "parentNode"); + t.assertTrue(parent.childNodes.length == 2); + + var firstChild = parent.firstChild; + t.assertTrue(firstChild !== null); + t.assertTrue(firstChild.tagName === "childNode"); + t.assertTrue(firstChild.childNodes.length == 1); + + var secondChild = firstChild.nextSibling; + t.assertTrue(secondChild !== null); + t.assertTrue(secondChild.tagName === "childNode"); + + var grandChild = firstChild.firstChild; + t.assertTrue(grandChild !== null); + t.assertTrue(grandChild.tagName === "grandchildNode"); + + }, + function testReadTextContent(t){ + var text = "This is a bunch of child text on the node"; + var simpleXml = "" + text + ""; + var document = dojox.data.dom.createDocument(simpleXml, "text/xml"); + + var topNode = document.firstChild; + t.assertTrue(topNode !== null); + t.assertTrue(topNode.tagName === "parentNode"); + t.assertTrue(text === dojox.data.dom.textContent(topNode)); + dojo._destroyElement(topNode); + t.assertTrue(document.firstChild === null); + }, + function testSetTextContent(t){ + var text = "This is a bunch of child text on the node"; + var text2 = "This is the new text"; + var simpleXml = "" + text + ""; + var document = dojox.data.dom.createDocument(simpleXml, "text/xml"); + + var topNode = document.firstChild; + t.assertTrue(topNode !== null); + t.assertTrue(topNode.tagName === "parentNode"); + t.assertTrue(text === dojox.data.dom.textContent(topNode)); + dojox.data.dom.textContent(topNode, text2); + t.assertTrue(text2 === dojox.data.dom.textContent(topNode)); + dojo._destroyElement(topNode); + t.assertTrue(document.firstChild === null); + + }, + function testReplaceChildrenArray(t){ + var simpleXml1 = ""; + var simpleXml2 = ""; + var doc1 = dojox.data.dom.createDocument(simpleXml1, "text/xml"); + var doc2 = dojox.data.dom.createDocument(simpleXml2, "text/xml"); + + var topNode1 = doc1.firstChild; + var topNode2 = doc2.firstChild; + t.assertTrue(topNode1 !== null); + t.assertTrue(topNode1.tagName === "parentNode"); + t.assertTrue(topNode2 !== null); + t.assertTrue(topNode2.tagName === "parentNode"); + dojox.data.dom.removeChildren(topNode1); + var newChildren=[]; + for(var i=0;i