1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2<html>
3	<head>
4		<title>Tests for the Helper functions</title>
5<!--
6  $Id: HelpersTestsOther.html 147 2006-12-20 22:53:19Z wingedfox $
7  $HeadURL: https://svn.debugger.ru/repos/jslibs/BrowserExtensions/tags/BrowserExtensions.003/tests/HelpersTestsOther.html $
8
9  Automated tests for the Helper functions
10  @author Ilya Lebedev <ilya@lebedev.net>
11-->
12        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
13        <title>BrowserExtensions/Helpers tests</title>
14        <link rel="stylesheet" type="text/css" href="../css/jsUnitStyle.css">
15        <script language="JavaScript" type="text/javascript" src="jsUnitCore.js"></script>
16        <script language="JavaScript" type="text/javascript" src="../helpers.js"></script>
17        <script language="JavaScript" type="text/javascript">
18
19            var div,p,span,em;
20            function setUpPage() {
21                inform('setUpPage()');
22                document.body.innerHTML = '<div id="testdiv1" class="testdiv1">'
23                                         +' <div id="testdiv2" class="testdiv2">'
24                                         +'  <p id="teestp1" class="testp1">'
25                                         +'   <span id="testspan1" class="testspan1">'
26                                         +'    <em id="testem1" class="testem1"> test </em>'
27                                         +'  </span></p></div></div>';
28                div = document.getElementById('testdiv1');
29                div2 = document.getElementById('testdiv2');
30                p = document.getElementById('testp1');
31                span = document.getElementById('testspan1');
32                em = document.getElementById('testem1');
33                setUpPageStatus = 'complete';
34            }
35
36            function testGetParent() {
37                assertEquals("Find self should return self", em, DOM.getParent(em, em));
38                assertEquals("Find parent should return parent", div, DOM.getParent(em, div));
39                assertEquals("Find from em with 1st param 'em' should return self", em, DOM.getParent(em,"em"));
40                assertEquals("Find from em with 1st param 'div' should return div with id=testdiv2", div2, DOM.getParent(em,"div"));
41                assertNull("Find unexistent node should return null", DOM.getParent(em,"td"));
42                assertEquals("Find from em with 1st param 'className' and 2nd 'testdiv1' should return div with id=testdiv1", div, DOM.getParent(em, "className", "testdiv1"));
43                assertNull("Find from em with 1st param 'className' and 2nd 'nothing' should return null", DOM.getParent(em, "className", "nothing"));
44            }
45
46            function testGluePath() {
47                assertEquals("gluePath will return empty string when no arguments specified", '', gluePath());
48                assertEquals("gluePath will return string 'as is' when only 1 argument specified", 'a', gluePath('a'));
49                assertEquals("gluePath will return string 'as is' when only 1 argument specified", '/a', gluePath('/a'));
50                assertEquals("gluePath will return string 'as is' when only 1 argument specified", '/a/', gluePath('/a/'));
51                assertEquals("gluePath will return string 'as is' when only 1 argument specified", 'a/', gluePath('a/'));
52                assertEquals("gluePath will not strip duplicate slashes in non-glued parts", '//a', gluePath('//a'));
53                assertEquals("gluePath will not strip duplicate slashes in non-glued parts", '//a//', gluePath('//a//'));
54                assertEquals("gluePath will not strip duplicate slashes in non-glued parts", 'a//', gluePath('a//'));
55                assertEquals("gluePath will not break URLs", 'http://test.com', gluePath('http://test.com'));
56                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'));
57                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'));
58            }
59
60
61        </script>
62    </head>
63    <body>
64        <h1>Tests for the Helpers functions</h1>
65        <p>This page contains tests for the Helpers functions. To see them, take a look at the source.</p>
66	</body>
67</html>
68