[Zope-CVS] CVS: Packages/Moztop/moztop/content/lib/tests - test_dav.html:1.1
Stephan Richter
srichter@cbu.edu
Sun, 30 Mar 2003 14:45:16 -0500
Update of /cvs-repository/Packages/Moztop/moztop/content/lib/tests
In directory cvs.zope.org:/tmp/cvs-serv19463/moztop/content/lib/tests
Added Files:
test_dav.html
Log Message:
Worked a lot on jsdav lib. All HTTP methods now have at least a stub
implementation and I think all of the XML Elements are mapped now (except
prop, which is quiet flexible - more than I could handle so far).
Started writing tests. Wow, this is a lot of work, but it really allows us
to find bugs and finish the error handling.
=== Added File Packages/Moztop/moztop/content/lib/tests/test_dav.html ===
<html>
<head>
<title>Test Page for the jsdav Library</title>
<link rel="stylesheet" type="text/css"
href="../../jsunit/css/jsUnitStyle.css">
<script id="test_script" type="application/x-javascript">
/*
TESTED
- DavDepth: constructor, set/getValue, createXML
- DavLockToken: constructor, set/getHref, createXML
- DavHref: constructor, set/getURL, createXML
TODO
- DavDepth: parseXML
- DavLockToken: parseXML
- DavHref: parseXML
*/
var serializer = new XMLSerializer();
function testDavDepthConstructor() {
var d = new DavDepth('0');
assertEquals("Test Depth Constructor with passed value.",
'0', d.value);
var d = new DavDepth();
assertEquals("Test Depth Constructor without passed value.",
DAV_RESOURCE_DEPTH, d.value);
}
function testDavDepthGetSetValue() {
var d = new DavDepth('0');
assertEquals("Test Depth getValue() function.", '0', d.getValue());
d.setValue('1')
assertEquals("Test Depth setValue() function.", '1', d.value);
try {
d.setValue('foo');
}
catch(error) {
assertEquals("Test Depth setValue() failure.",
("The value 'foo' is not a valid depth. Use one of the " +
"following values instead: 0, 1, infinity"),
error.serialize());
}
}
function _XXX_testDavDepthParseXML() {
throw 'IncompleteTest';
}
function testDavDepthCreateXML() {
var d = new DavDepth('0');
var doc = document.implementation.createDocument("DAV:", "D:test",
null);
var node = doc.documentElement;
d.createXML(node, doc);
assertEquals("Test DavDepth serializeXML() function.",
'<a0:depth xmlns:a0="DAV:">0</a0:depth>',
serializer.serializeToString(node));
}
function testDavDepthConstants() {
assertEquals("Test DAV_RESOURCE_DEPTH value.", "0", DAV_RESOURCE_DEPTH);
assertEquals("Test DAV_CHILDREN_DEPTH value.", "1", DAV_CHILDREN_DEPTH);
assertEquals("Test DAV_INFINITY_DEPTH value.",
"infinity", DAV_INFINITY_DEPTH);
}
function testDavLockTokenConstructor() {
var href = new DavHref('http://test.com/test.html');
var lt = new DavLockToken(href);
assertEquals("Test LockToken Constructor with passed href value.",
href, lt.href);
var lt = new DavLockToken();
assertEquals("Test LockToken Constructor without passed href value.",
null, lt.href);
}
function testDavLockTokenGetSetHref() {
var href = new DavHref('http://test.com/test.html');
var lt = new DavLockToken(href);
assertEquals("Test LockToken getHref() function.",
href, lt.getHref());
href = new DavHref('http://test.com/test1.html');
lt.setHref(href);
assertEquals("Test LockToken setHref() function.",
href, lt.href);
try {
lt.setHref('http://test.com/test.com');
}
catch(error) {
assertEquals("Test LockToken setHref() failure.",
"Expected object type to be [object], but is [string].",
error.serialize());
}
}
function _XXX_testDavLockTokenParseXML() {
throw 'IncompleteTest';
}
function testDavLockTokenCreateXML() {
var href = new DavHref('http://test.com/test.html');
var lt = new DavLockToken(href);
var doc = document.implementation.createDocument("DAV:", "D:test",
null);
var node = doc.documentElement;
lt.createXML(node, doc);
assertEquals(
"Test DavLockToken serializeXML() function.",
'<a0:locktoken xmlns:a0="DAV:">' +
'<a0:href>http://test.com/test.html</a0:href>'+
'</a0:locktoken>',
serializer.serializeToString(node));
}
function testDavHrefConstructor() {
var href = new DavHref('http://test.com/test.html');
assertEquals("Test Href Constructor with passed href value.",
'http://test.com/test.html', href.url);
var href = new DavHref();
assertEquals("Test Href Constructor without passed href value.",
null, href.url);
}
function testDavHrefGetSetURL() {
var href = new DavHref('http://test.com/test.html');
assertEquals("Test Href getURL() function.",
'http://test.com/test.html', href.getURL());
href.setURL('http://test.com/test1.html');
assertEquals("Test Href setURL() function.",
'http://test.com/test1.html', href.url);
}
function _XXX_testDavHrefParseXML() {
throw 'IncompleteTest';
}
function testDavHrefCreateXML() {
var href = new DavHref('http://test.com/t.html');
var doc = document.implementation.createDocument("DAV:", "D:test",
null);
var node = doc.documentElement;
href.createXML(node, doc);
assertEquals(
"Test DavHref serializeXML() function.",
'<a0:href xmlns:a0="DAV:">http://test.com/t.html</a0:href>',
serializer.serializeToString(node));
}
</script>
<script type="application/x-javascript"
src="../../jsunit/app/jsUnitCore.js" />
<script type="application/x-javascript"
src="../jsdav.js" />
</head>
<body>
<h1>The JS WebDAV Library Unit tests.</h1>
<p>This unit test collection should test all apspects of the library.</p>
</body>
</html>