forked from madrobby/scriptaculous
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
script.aculo.us: Finetuning unittest.js + even more unit tests
git-svn-id: http://svn.rubyonrails.org/rails/spinoffs/scriptaculous@2072 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
- Loading branch information
Showing
9 changed files
with
215 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | ||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | ||
<head> | ||
<title>script.aculo.us Unit test file</title> | ||
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> | ||
<script src="../../lib/prototype.js" type="text/javascript"></script> | ||
<script src="../../src/scriptaculous.js" type="text/javascript"></script> | ||
<script src="../../src/unittest.js" type="text/javascript"></script> | ||
<link rel="stylesheet" href="../test.css" type="text/css" /> | ||
<style type="text/css" media="screen"> | ||
#style_test_1 { color:rgb(0, 0, 255); background-color: rgb(0, 0, 255); } | ||
blah { color:rgb(0, 255, 0); } | ||
</style> | ||
</head> | ||
<body> | ||
<h1>script.aculo.us Unit test file</h1> | ||
<p> | ||
Test element extensions | ||
</p> | ||
|
||
<!-- Log output --> | ||
<div id="testlog"> </div> | ||
|
||
<!-- Test elements follow --> | ||
<div id="test_1" class="a bbbbbbbbbbbb cccccccccc dddd"> </div> | ||
|
||
<div id="test_2" class="classA-foobar classB-foobar"> </div> <span> </span> | ||
|
||
<div id="style_test_1" style="display:none;"></div> | ||
<div id="style_test_2" class="blah" style="font-size:11px;"></div> | ||
|
||
<div id="test_whitespace"> <span> </span> | ||
|
||
|
||
|
||
<div><div></div> </div><span> </span> | ||
</div> | ||
|
||
<!-- Tests follow --> | ||
<script type="text/javascript" language="javascript" charset="utf-8"> | ||
// <![CDATA[ | ||
|
||
new Test.Unit.Runner({ | ||
|
||
testElementGetStyle: function() { with(this) { | ||
assertEqual("none", | ||
Element.getStyle('style_test_1','display')); | ||
// not displayed, so "null" ("auto" is tranlated to "null") | ||
assertNull(Element.getStyle('style_test_1','width')); | ||
assertEqual("static",Element.getStyle('style_test_1','position'), "Note: Safari bug! (see http://bugzilla.opendarwin.org/show_bug.cgi?id=4125)"); | ||
// from id rule | ||
assertEqual("rgb(0, 0, 255)", | ||
Element.getStyle('style_test_1','color')); | ||
assertEqual("rgb(0, 0, 255)", | ||
Element.getStyle('style_test_1','background-color')); | ||
|
||
assertEqual("block", | ||
Element.getStyle('style_test_2','display')); | ||
assertNotNull(Element.getStyle('style_test_2','width')); | ||
assertEqual("static",Element.getStyle('style_test_1','position')); | ||
// from style | ||
assertEqual("11px", | ||
Element.getStyle('style_test_2','font-size')); | ||
// from class | ||
assertEqual("rgb(0, 0, 255)", | ||
Element.getStyle('style_test_1','background-color')); | ||
}}, | ||
|
||
testElementCleanWhitespace: function() { with(this) { | ||
Element.cleanWhitespace("test_whitespace"); | ||
assertEqual(3, $("test_whitespace").childNodes.length); | ||
|
||
assertEqual(1, $("test_whitespace").firstChild.nodeType); | ||
assertEqual('SPAN', $("test_whitespace").firstChild.tagName); | ||
|
||
assertEqual(1, $("test_whitespace").firstChild.nextSibling.nodeType); | ||
assertEqual('DIV', $("test_whitespace").firstChild.nextSibling.tagName); | ||
|
||
assertEqual(1, $("test_whitespace").firstChild.nextSibling.nextSibling.nodeType); | ||
assertEqual('SPAN', $("test_whitespace").firstChild.nextSibling.nextSibling.tagName); | ||
}}, | ||
|
||
testElementClassHas: function() { with(this) { | ||
assert(Element.Class.has("test_1","a")); | ||
assert(Element.Class.has("test_1","dddd")); | ||
assert(Element.Class.has("test_1","bbbbbbbbbbbb")); | ||
assert(!Element.Class.has("test_1","bbbbbbbbbbb")); | ||
assert(!Element.Class.has("test_1","bbbbbbbbbbbbbb")); | ||
|
||
assert(Element.Class.has("test_1",["a"])); | ||
assert(Element.Class.has("test_1",["dddd"])); | ||
assert(Element.Class.has("test_1",["bbbbbbbbbbbb"])); | ||
assert(!Element.Class.has("test_1",["bbbbbbbbbbb"])); | ||
assert(!Element.Class.has("test_1",["bbbbbbbbbbbbbb"])); | ||
|
||
assert(!Element.Class.has("test_1",["x","a"])); | ||
assert(!Element.Class.has("test_1",["x","dddd"])); | ||
assert(!Element.Class.has("test_1",["x","bbbbbbbbbbbb"])); | ||
assert(!Element.Class.has("test_1",["x","bbbbbbbbbbb"])); | ||
assert(!Element.Class.has("test_1",["x","bbbbbbbbbbbbbb"])); | ||
|
||
assert(Element.Class.has("test_1",["a","a"])); | ||
assert(Element.Class.has("test_1",["a","dddd"])); | ||
assert(Element.Class.has("test_1",["a","bbbbbbbbbbbb"])); | ||
assert(!Element.Class.has("test_1",["a","bbbbbbbbbbb"])); | ||
assert(!Element.Class.has("test_1",["a","bbbbbbbbbbbbbb"])); | ||
|
||
assert(Element.Class.has("test_2","classA-foobar")); | ||
assert(Element.Class.has("test_2","classB-foobar")); | ||
assert(!Element.Class.has("test_2","classA")); | ||
}}, | ||
|
||
testElementClassHasAny: function() { with(this) { | ||
assert(Element.Class.has_any("test_1","a")); | ||
assert(Element.Class.has_any("test_1","dddd")); | ||
assert(Element.Class.has_any("test_1","bbbbbbbbbbbb")); | ||
assert(!Element.Class.has_any("test_1","bbbbbbbbbbb")); | ||
assert(!Element.Class.has_any("test_1","bbbbbbbbbbbbbb")); | ||
|
||
assert(Element.Class.has_any("test_1",["a"])); | ||
assert(Element.Class.has_any("test_1",["dddd"])); | ||
assert(Element.Class.has_any("test_1",["bbbbbbbbbbbb"])); | ||
assert(!Element.Class.has_any("test_1",["bbbbbbbbbbb"])); | ||
assert(!Element.Class.has_any("test_1",["bbbbbbbbbbbbbb"])); | ||
|
||
assert(Element.Class.has_any("test_1",["x","a"])); | ||
assert(Element.Class.has_any("test_1",["x","dddd"])); | ||
assert(Element.Class.has_any("test_1",["x","bbbbbbbbbbbb"])); | ||
assert(!Element.Class.has_any("test_1",["x","bbbbbbbbbbb"])); | ||
assert(!Element.Class.has_any("test_1",["x","bbbbbbbbbbbbbb"])); | ||
|
||
assert(Element.Class.has_any("test_1",["a","a"])); | ||
assert(Element.Class.has_any("test_1",["a","dddd"])); | ||
assert(Element.Class.has_any("test_1",["a","bbbbbbbbbbbb"])); | ||
assert(Element.Class.has_any("test_1",["a","bbbbbbbbbbb"])); | ||
assert(Element.Class.has_any("test_1",["a","bbbbbbbbbbbbbb"])); | ||
}} | ||
|
||
}, "testlog"); | ||
// ]]> | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.