@seanox/aspect-js
Version:
full stack JavaScript framework for SPAs incl. reactivity rendering, mvc / mvvm, models, expression language, datasource, routing, paths, unit test and some more
121 lines (107 loc) • 5.88 kB
HTML
<html>
<head>
<meta charset="ISO-8859-1">
<title>Seanox aspect-js test environment</title>
<style>
body {
font-family: monospace;
white-space: pre;
}
</style>
<script src="aspect-js.js"></script>
<script type="text/javascript">
Test.activate();
Test.create({test() {
Assert.assertNull(Path.normalize());
Assert.assertNull(Path.normalize(undefined));
Assert.assertNull(Path.normalize(null));
}});
Test.create({test() {
Assert.assertEquals("#", Path.normalize(""));
Assert.assertEquals("#", Path.normalize("#"));
Assert.assertEquals("#", Path.normalize("##"));
Assert.assertEquals("#", Path.normalize("###"));
Assert.assertEquals("#", Path.normalize("####"));
Assert.assertEquals("#", Path.normalize("#####"));
}});
Test.create({test() {
Assert.assertEquals("#1#2#3", Path.normalize("#1#2#3"));
Assert.assertEquals("#1#2#3", Path.normalize("#1#2#3", "#"));
Assert.assertEquals("#x#y#z", Path.normalize("#x#y#z#", ""));
Assert.assertEquals("#x#y", Path.normalize("#x#y#z##", ""));
Assert.assertEquals("#x", Path.normalize("#x#y#z###", ""));
Assert.assertEquals("#x#y#z", Path.normalize("#x#y#z#", "#"));
Assert.assertEquals("#x#y", Path.normalize("#x#y#z##", "#"));
Assert.assertEquals("#x", Path.normalize("#x#y#z###", "#"));
}});
Test.create({test() {
Assert.assertEquals("#aaa", Path.normalize("aaa"));
Assert.assertEquals("#aaa#bbb", Path.normalize("aaa#bbb"));
Assert.assertEquals("#aaa#bbb#ccc", Path.normalize("aaa#bbb#ccc"));
Assert.assertEquals("#aaa#bbb#ccc", Path.normalize("aaa#bbb#ccc#"));
Assert.assertEquals("#aaa#bbb", Path.normalize("aaa#bbb#ccc##"));
Assert.assertEquals("#aaa", Path.normalize("aaa#bbb#ccc###"));
Assert.assertEquals("#", Path.normalize("aaa#bbb#ccc####"));
Assert.assertEquals("#", Path.normalize("aaa#bbb#ccc#####"));
}});
Test.create({test() {
Assert.assertEquals("#aaa", Path.normalize("#aaa"));
Assert.assertEquals("#aaa#bbb", Path.normalize("#aaa#bbb"));
Assert.assertEquals("#aaa#bbb#ccc", Path.normalize("#aaa#bbb#ccc"));
Assert.assertEquals("#aaa#bbb#ccc", Path.normalize("#aaa#bbb#ccc#"));
Assert.assertEquals("#aaa#bbb", Path.normalize("#aaa#bbb#ccc##"));
Assert.assertEquals("#aaa", Path.normalize("#aaa#bbb#ccc###"));
Assert.assertEquals("#", Path.normalize("#aaa#bbb#ccc####"));
Assert.assertEquals("#", Path.normalize("#aaa#bbb#ccc#####"));
}});
Test.create({test() {
Assert.assertEquals("#a#b#c#d#f", Path.normalize("#a#b#c#d#e##f"));
Assert.assertEquals("#a#b#c#f", Path.normalize("#a#b#c#d#e###f"));
Assert.assertEquals("#f", Path.normalize("###f"));
Assert.assertEquals("#f", Path.normalize("####f"));
}});
Test.create({test() {
Assert.assertEquals("#x#y#z#a#b#c#d#f", Path.normalize("#x#y#z", "#a#b#c#d#e##f"));
Assert.assertEquals("#x#y#z#a#b#c#f", Path.normalize("#x#y#z", "#a#b#c#d#e###f"));
Assert.assertEquals("#x#f", Path.normalize("#x#y#z", "###f"));
Assert.assertEquals("#f", Path.normalize("#x#y#z", "####f"));
Assert.assertEquals("#f", Path.normalize("#x#y#z", "#####f"));
Assert.assertEquals("#f", Path.normalize("#x#y#z", "######f"));
}});
Test.create({test() {
// Looks strange and like an error, but it's not :-)
// Because 7-bit ASCII is supported in the path, a URI is valid.
// This is necessary so that parameters can be used in the path.
Assert.assertEquals("#httpx://local/#x#y#z#httpx://local/#a#b#c#d#f", Path.normalize("httpx://local/#x#y#z", "httpx://local/#a#b#c#d#e##f"));
Assert.assertEquals("#httpx://local/#x#y#z#httpx://local/#a#b#c#f", Path.normalize("httpx://local/#x#y#z", "httpx://local/#a#b#c#d#e###f"));
Assert.assertEquals("#httpx://local/#x#y#f", Path.normalize("httpx://local/#x#y#z", "httpx://local/###f"));
Assert.assertEquals("#httpx://local#x#f", Path.normalize("httpx://local#x#y#z", "httpx://local####f"));
Assert.assertEquals("#httpx://local#x#f", Path.normalize("httpx://local#x#y#z", "httpx://local####f"));
Assert.assertEquals("#httpx://local#f", Path.normalize("httpx://local#x#y#z", "httpx://local#####f"));
Assert.assertEquals("#f", Path.normalize("httpx://local#x#y#z", "httpx://local######f"));
}});
Test.create({expected:/\bInvalid data type/i, test() {
Path.normalize({});
}});
Test.create({expected:/\bInvalid data type/i, test() {
Path.normalize(true);
}});
Test.create({expected:/\bInvalid data type/i, test() {
Path.normalize({}, "#");
}});
Test.create({expected:/\bInvalid data type/i, test() {
Path.normalize(true, "#");
}});
Test.create({test() {
Assert.assertEquals("#a#b#c#d", Path.normalize("#a#b#c#d"));
Assert.assertEquals("#a#b#c#x", Path.normalize("#a#b#c#d##x"));
Assert.assertEquals("#a#b#x", Path.normalize("#a#b#c#d###x"));
Assert.assertEquals("#a#x", Path.normalize("#a#b#c#d####x"));
}});
Test.start({auto:true});
</script>
</head>
<body>
</body>
</html>