<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Tests for the Helper functions</title>
<!--
$Id: HelpersTestsOther.html 147 2006-12-20 22:53:19Z wingedfox $
$HeadURL: https://svn.debugger.ru/repos/jslibs/BrowserExtensions/tags/BrowserExtensions.003/tests/HelpersTestsOther.html $
Automated tests for the Helper functions
@author Ilya Lebedev <ilya@lebedev.net>
-->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>BrowserExtensions/Helpers tests</title>
<link rel="stylesheet" type="text/css" href="../css/jsUnitStyle.css">
<script language="JavaScript" type="text/javascript" src="jsUnitCore.js"></script>
<script language="JavaScript" type="text/javascript" src="../helpers.js"></script>
<script language="JavaScript" type="text/javascript">
var div,p,span,em;
function setUpPage() {
inform('setUpPage()');
document.body.innerHTML = '<div id="testdiv1" class="testdiv1">'
+' <div id="testdiv2" class="testdiv2">'
+' <p id="teestp1" class="testp1">'
+' <span id="testspan1" class="testspan1">'
+' <em id="testem1" class="testem1"> test </em>'
+' </span></p></div></div>';
div = document.getElementById('testdiv1');
div2 = document.getElementById('testdiv2');
p = document.getElementById('testp1');
span = document.getElementById('testspan1');
em = document.getElementById('testem1');
setUpPageStatus = 'complete';
}
function testGetParent() {
assertEquals("Find self should return self", em, DOM.getParent(em, em));
assertEquals("Find parent should return parent", div, DOM.getParent(em, div));
assertEquals("Find from em with 1st param 'em' should return self", em, DOM.getParent(em,"em"));
assertEquals("Find from em with 1st param 'div' should return div with id=testdiv2", div2, DOM.getParent(em,"div"));
assertNull("Find unexistent node should return null", DOM.getParent(em,"td"));
assertEquals("Find from em with 1st param 'className' and 2nd 'testdiv1' should return div with id=testdiv1", div, DOM.getParent(em, "className", "testdiv1"));
assertNull("Find from em with 1st param 'className' and 2nd 'nothing' should return null", DOM.getParent(em, "className", "nothing"));
}
function testGluePath() {
assertEquals("gluePath will return empty string when no arguments specified", '', gluePath());
assertEquals("gluePath will return string 'as is' when only 1 argument specified", 'a', gluePath('a'));
assertEquals("gluePath will return string 'as is' when only 1 argument specified", '/a', gluePath('/a'));
assertEquals("gluePath will return string 'as is' when only 1 argument specified", '/a/', gluePath('/a/'));
assertEquals("gluePath will return string 'as is' when only 1 argument specified", 'a/', gluePath('a/'));
assertEquals("gluePath will not strip duplicate slashes in non-glued parts", '//a', gluePath('//a'));
assertEquals("gluePath will not strip duplicate slashes in non-glued parts", '//a//', gluePath('//a//'));
assertEquals("gluePath will not strip duplicate slashes in non-glued parts", 'a//', gluePath('a//'));
assertEquals("gluePath will not break URLs", 'http://test.com', gluePath('http://test.com'));
assertEquals("gluePath will glue the strings and numbers", 'http://test.com/1/path/to/file.html', gluePath('http://test.com', 1, 'path/to/file.html'));
assertEquals("gluePath will skip arguments, that does not match the strings and numbers", 'http://test.com/1/path/to/file.html', gluePath('http://test.com',{}, 1, [], /34/, 'path/to/file.html'));
}
</script>
</head>
<body>
<h1>Tests for the Helpers functions</h1>
<p>This page contains tests for the Helpers functions. To see them, take a look at the source.</p>
</body>
</html>