headless-squirrel 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +55 -0
- data/Rakefile +27 -0
- data/bin/jstest +10 -0
- data/lib/headless_squirrel.rb +2 -0
- data/lib/headless_squirrel/console.rb +24 -0
- data/lib/headless_squirrel/runner.rb +70 -0
- data/lib/headless_squirrel/test.rb +17 -0
- data/lib/headless_squirrel/test_case.rb +158 -0
- data/test/fixtures/a_unit_test.html +27 -0
- data/test/fixtures/a_unit_test.js +22 -0
- data/test/fixtures/syntax_error.html +27 -0
- data/test/fixtures/syntax_error.js +5 -0
- data/test/fixtures/type_error.html +27 -0
- data/test/fixtures/type_error.js +1 -0
- data/test/regression/prototype/unit/ajax_test.html +29 -0
- data/test/regression/prototype/unit/array_test.html +28 -0
- data/test/regression/prototype/unit/assets/prototype.js +4900 -0
- data/test/regression/prototype/unit/assets/unittest.css +50 -0
- data/test/regression/prototype/unit/assets/unittest.js +615 -0
- data/test/regression/prototype/unit/assets/unittest_transport.js +1 -0
- data/test/regression/prototype/unit/base_test.html +27 -0
- data/test/regression/prototype/unit/class_test.html +27 -0
- data/test/regression/prototype/unit/date_test.html +27 -0
- data/test/regression/prototype/unit/dom_test.html +304 -0
- data/test/regression/prototype/unit/element_mixins_test.html +30 -0
- data/test/regression/prototype/unit/enumerable_test.html +35 -0
- data/test/regression/prototype/unit/event_test.html +31 -0
- data/test/regression/prototype/unit/fixtures/ajax.html +2 -0
- data/test/regression/prototype/unit/fixtures/ajax.js +42 -0
- data/test/regression/prototype/unit/fixtures/array.html +1 -0
- data/test/regression/prototype/unit/fixtures/class.js +83 -0
- data/test/regression/prototype/unit/fixtures/content.html +1 -0
- data/test/regression/prototype/unit/fixtures/data.json +1 -0
- data/test/regression/prototype/unit/fixtures/dom.css +84 -0
- data/test/regression/prototype/unit/fixtures/dom.html +278 -0
- data/test/regression/prototype/unit/fixtures/dom.js +17 -0
- data/test/regression/prototype/unit/fixtures/element_mixins.html +4 -0
- data/test/regression/prototype/unit/fixtures/element_mixins.js +2 -0
- data/test/regression/prototype/unit/fixtures/empty.html +0 -0
- data/test/regression/prototype/unit/fixtures/empty.js +1 -0
- data/test/regression/prototype/unit/fixtures/enumerable.html +8 -0
- data/test/regression/prototype/unit/fixtures/enumerable.js +23 -0
- data/test/regression/prototype/unit/fixtures/event.html +4 -0
- data/test/regression/prototype/unit/fixtures/form.html +108 -0
- data/test/regression/prototype/unit/fixtures/function.js +13 -0
- data/test/regression/prototype/unit/fixtures/hash.js +25 -0
- data/test/regression/prototype/unit/fixtures/hello.js +1 -0
- data/test/regression/prototype/unit/fixtures/logo.gif +0 -0
- data/test/regression/prototype/unit/fixtures/object.html +6 -0
- data/test/regression/prototype/unit/fixtures/object.js +7 -0
- data/test/regression/prototype/unit/fixtures/position.html +9 -0
- data/test/regression/prototype/unit/fixtures/selector.html +71 -0
- data/test/regression/prototype/unit/fixtures/string.js +8 -0
- data/test/regression/prototype/unit/fixtures/unittest.html +18 -0
- data/test/regression/prototype/unit/form_test.html +135 -0
- data/test/regression/prototype/unit/function_test.html +27 -0
- data/test/regression/prototype/unit/hash_test.html +27 -0
- data/test/regression/prototype/unit/number_test.html +27 -0
- data/test/regression/prototype/unit/object_test.html +32 -0
- data/test/regression/prototype/unit/periodical_executer_test.html +27 -0
- data/test/regression/prototype/unit/position_test.html +36 -0
- data/test/regression/prototype/unit/prototype_test.html +27 -0
- data/test/regression/prototype/unit/range_test.html +27 -0
- data/test/regression/prototype/unit/regexp_test.html +27 -0
- data/test/regression/prototype/unit/selector_test.html +98 -0
- data/test/regression/prototype/unit/string_test.html +27 -0
- data/test/regression/prototype/unit/tests/ajax_test.js +379 -0
- data/test/regression/prototype/unit/tests/array_test.js +186 -0
- data/test/regression/prototype/unit/tests/base_test.js +43 -0
- data/test/regression/prototype/unit/tests/class_test.js +136 -0
- data/test/regression/prototype/unit/tests/date_test.js +5 -0
- data/test/regression/prototype/unit/tests/dom_test.js +1493 -0
- data/test/regression/prototype/unit/tests/element_mixins_test.js +32 -0
- data/test/regression/prototype/unit/tests/enumerable_test.js +271 -0
- data/test/regression/prototype/unit/tests/event_test.js +235 -0
- data/test/regression/prototype/unit/tests/form_test.js +382 -0
- data/test/regression/prototype/unit/tests/function_test.js +133 -0
- data/test/regression/prototype/unit/tests/hash_test.js +178 -0
- data/test/regression/prototype/unit/tests/number_test.js +44 -0
- data/test/regression/prototype/unit/tests/object_test.js +180 -0
- data/test/regression/prototype/unit/tests/periodical_executer_test.js +15 -0
- data/test/regression/prototype/unit/tests/position_test.js +44 -0
- data/test/regression/prototype/unit/tests/prototype_test.js +43 -0
- data/test/regression/prototype/unit/tests/range_test.js +58 -0
- data/test/regression/prototype/unit/tests/regexp_test.js +42 -0
- data/test/regression/prototype/unit/tests/selector_test.js +408 -0
- data/test/regression/prototype/unit/tests/string_test.js +548 -0
- data/test/regression/prototype/unit/tests/unittest_test.js +148 -0
- data/test/regression/prototype/unit/unittest_test.html +45 -0
- data/test/regression/prototype/upstream +1 -0
- data/test/regression/scriptaculous/unit/_ajax_inplaceeditor_ipce_alt_text.html +1 -0
- data/test/regression/scriptaculous/unit/_ajax_inplaceeditor_ipce_collection.js +1 -0
- data/test/regression/scriptaculous/unit/_ajax_inplaceeditor_result.html +1 -0
- data/test/regression/scriptaculous/unit/_ajax_inplaceeditor_result2.html +1 -0
- data/test/regression/scriptaculous/unit/_ajax_inplaceeditor_tagged.html +1 -0
- data/test/regression/scriptaculous/unit/_ajax_inplaceeditor_text.html +1 -0
- data/test/regression/scriptaculous/unit/_ajax_updater_result.html +20 -0
- data/test/regression/scriptaculous/unit/_autocomplete_result.html +11 -0
- data/test/regression/scriptaculous/unit/_autocomplete_result_nobr.html +1 -0
- data/test/regression/scriptaculous/unit/ajax_autocompleter_test.html +243 -0
- data/test/regression/scriptaculous/unit/ajax_inplaceeditor_test.html +895 -0
- data/test/regression/scriptaculous/unit/assets/builder.js +134 -0
- data/test/regression/scriptaculous/unit/assets/controls.js +963 -0
- data/test/regression/scriptaculous/unit/assets/dragdrop.js +973 -0
- data/test/regression/scriptaculous/unit/assets/effects.js +1122 -0
- data/test/regression/scriptaculous/unit/assets/javascripttest.rb +203 -0
- data/test/regression/scriptaculous/unit/assets/prototype.js +4320 -0
- data/test/regression/scriptaculous/unit/assets/scriptaculous.js +66 -0
- data/test/regression/scriptaculous/unit/assets/slider.js +273 -0
- data/test/regression/scriptaculous/unit/assets/sound.js +57 -0
- data/test/regression/scriptaculous/unit/assets/unittest.js +566 -0
- data/test/regression/scriptaculous/unit/bdd_test.html +150 -0
- data/test/regression/scriptaculous/unit/builder_test.html +262 -0
- data/test/regression/scriptaculous/unit/dragdrop_test.html +131 -0
- data/test/regression/scriptaculous/unit/effects_test.html +547 -0
- data/test/regression/scriptaculous/unit/element_test.html +116 -0
- data/test/regression/scriptaculous/unit/icon.png +0 -0
- data/test/regression/scriptaculous/unit/index.html +70 -0
- data/test/regression/scriptaculous/unit/loading_test.html +41 -0
- data/test/regression/scriptaculous/unit/position_clone_test.html +312 -0
- data/test/regression/scriptaculous/unit/slider_test.html +437 -0
- data/test/regression/scriptaculous/unit/sortable_test.html +205 -0
- data/test/regression/scriptaculous/unit/string_test.html +71 -0
- data/test/regression/scriptaculous/unit/unittest_test.html +154 -0
- data/test/regression/scriptaculous/upstream +1 -0
- data/test/test_helper.rb +20 -0
- data/test/unit/runner_test.rb +165 -0
- data/test/unit/test_case_test.rb +207 -0
- data/test/unit/test_test.rb +24 -0
- metadata +209 -0
@@ -0,0 +1,150 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<title>script.aculo.us Unit test file</title>
|
6
|
+
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
7
|
+
<script src="assets/prototype.js" type="text/javascript"></script>
|
8
|
+
<script src="assets/scriptaculous.js" type="text/javascript"></script>
|
9
|
+
<script src="assets/unittest.js" type="text/javascript"></script>
|
10
|
+
<link rel="stylesheet" href="../test.css" type="text/css" />
|
11
|
+
</head>
|
12
|
+
<body>
|
13
|
+
<h1>script.aculo.us Unit test file</h1>
|
14
|
+
|
15
|
+
<!-- Log output -->
|
16
|
+
<div id="testlog"> </div>
|
17
|
+
|
18
|
+
<div id="d">initial</div>
|
19
|
+
|
20
|
+
<!-- Tests follow -->
|
21
|
+
<script type="text/javascript" language="javascript" charset="utf-8">
|
22
|
+
// <![CDATA[
|
23
|
+
var moo = 0;
|
24
|
+
|
25
|
+
var assertMethods = [];
|
26
|
+
for(method in Test.Unit.Assertions.prototype) {
|
27
|
+
if(/^assert/.test(method)) assertMethods.push(method);
|
28
|
+
}
|
29
|
+
|
30
|
+
var testObj = {
|
31
|
+
isNice: function(){
|
32
|
+
return true;
|
33
|
+
},
|
34
|
+
isBroken: function(){
|
35
|
+
return false;
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
Test.context("BDD-style testing",{
|
40
|
+
|
41
|
+
setup: function() {
|
42
|
+
$('d').update('setup!');
|
43
|
+
moo++;
|
44
|
+
},
|
45
|
+
|
46
|
+
teardown: function() {
|
47
|
+
moo--;
|
48
|
+
},
|
49
|
+
|
50
|
+
'should run setup before each specification': function(){
|
51
|
+
assert($('d').innerHTML == 'setup!');
|
52
|
+
assert(moo == 1);
|
53
|
+
},
|
54
|
+
|
55
|
+
'should run teardown after each specification': function(){
|
56
|
+
assert(moo == 1);
|
57
|
+
},
|
58
|
+
|
59
|
+
'should provide extensions to tie in isSomething and respondsTo object methods': function(){
|
60
|
+
Object.extend(testObj, Test.BDDMethods);
|
61
|
+
|
62
|
+
testObj.shouldBe('nice');
|
63
|
+
testObj.shouldNotBe('broken');
|
64
|
+
|
65
|
+
testObj.shouldRespondTo('isNice');
|
66
|
+
testObj.shouldRespondTo('isBroken');
|
67
|
+
},
|
68
|
+
|
69
|
+
'should automatically add extensions to strings': function(){
|
70
|
+
'a'.shouldEqual('a');
|
71
|
+
'a'.shouldNotEqual('b');
|
72
|
+
'a'.shouldNotBeNull();
|
73
|
+
'a'.shouldBeA(String);
|
74
|
+
|
75
|
+
var aString = 'boo!';
|
76
|
+
aString.shouldEqual('boo!');
|
77
|
+
aString.shouldBeA(String);
|
78
|
+
aString.shouldNotBeA(Number);
|
79
|
+
},
|
80
|
+
|
81
|
+
'should automatically add extensions to numbers': function(){
|
82
|
+
var n = 123;
|
83
|
+
n.shouldEqual(123);
|
84
|
+
n.shouldNotEqual(4);
|
85
|
+
|
86
|
+
n.shouldBeA(Number);
|
87
|
+
n.shouldNotBeA(Test);
|
88
|
+
},
|
89
|
+
|
90
|
+
'should automatically add extensions to arrays': function(){
|
91
|
+
['a'].shouldNotBeA(String);
|
92
|
+
[1,2,3].shouldBeAn(Array);
|
93
|
+
[1,2,3].shouldEqualEnum([1,2,3]);
|
94
|
+
},
|
95
|
+
|
96
|
+
'should automatically add extensions to booleans': function(){
|
97
|
+
var theTruth = true;
|
98
|
+
var lies = false;
|
99
|
+
|
100
|
+
theTruth.shouldNotBeA(String);
|
101
|
+
lies.shouldBeA(Boolean);
|
102
|
+
'false'.shouldNotBeA(Boolean);
|
103
|
+
|
104
|
+
theTruth.shouldEqual(true);
|
105
|
+
lies.shouldNotEqual(true);
|
106
|
+
},
|
107
|
+
|
108
|
+
'should support the eval() method': function(){
|
109
|
+
eval('2*2').shouldEqual(4);
|
110
|
+
},
|
111
|
+
|
112
|
+
'should support equality assertion': function(){
|
113
|
+
assertEqual(1, 1);
|
114
|
+
assertEqual('a', 'a');
|
115
|
+
assertEqual(1, '1');
|
116
|
+
|
117
|
+
var x = 1;
|
118
|
+
var y = 1;
|
119
|
+
assertEqual(1, x)
|
120
|
+
assertEqual(x, y);
|
121
|
+
},
|
122
|
+
|
123
|
+
'should provide all assertions': function(){
|
124
|
+
assertMethods.each(function(m){
|
125
|
+
assert(typeof this[m] == 'function');
|
126
|
+
}.bind(this));
|
127
|
+
},
|
128
|
+
|
129
|
+
'should support deferred execution': function(){
|
130
|
+
wait(10,function(){
|
131
|
+
'a'.shouldEqual('a');
|
132
|
+
});
|
133
|
+
|
134
|
+
wait(10,function(){
|
135
|
+
'a'.shouldEqual('a');
|
136
|
+
wait(10,function(){
|
137
|
+
'a'.shouldEqual('a');
|
138
|
+
wait(10,function(){
|
139
|
+
'a'.shouldEqual('a');
|
140
|
+
});
|
141
|
+
});
|
142
|
+
});
|
143
|
+
}
|
144
|
+
|
145
|
+
});
|
146
|
+
|
147
|
+
// ]]>
|
148
|
+
</script>
|
149
|
+
</body>
|
150
|
+
</html>
|
@@ -0,0 +1,262 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<title>script.aculo.us Unit test file</title>
|
6
|
+
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
7
|
+
<script src="assets/prototype.js" type="text/javascript"></script>
|
8
|
+
<script src="assets/scriptaculous.js" type="text/javascript"></script>
|
9
|
+
<script src="assets/unittest.js" type="text/javascript"></script>
|
10
|
+
<link rel="stylesheet" href="../test.css" type="text/css" />
|
11
|
+
</head>
|
12
|
+
<body>
|
13
|
+
<h1>script.aculo.us Unit test file</h1>
|
14
|
+
<p>
|
15
|
+
Tests for builder.js
|
16
|
+
</p>
|
17
|
+
|
18
|
+
<!-- Log output -->
|
19
|
+
<div id="testlog"> </div>
|
20
|
+
|
21
|
+
<div id="result"></div>
|
22
|
+
|
23
|
+
<!-- Tests follow -->
|
24
|
+
<script type="text/javascript" language="javascript" charset="utf-8">
|
25
|
+
// <![CDATA[
|
26
|
+
|
27
|
+
// Serializes a node and it's contents to plain old HTML
|
28
|
+
// IMPORTANT: style attributes can't be correctly serialized cross-browser wise,
|
29
|
+
// so the contents of style attributes must match what IE thinks is correct
|
30
|
+
function serializeNode(node){
|
31
|
+
if(node.nodeType == 3) return node.nodeValue;
|
32
|
+
node = $(node);
|
33
|
+
var tag = node.tagName.toLowerCase();
|
34
|
+
return '<' + ([tag].concat($A(node.attributes).map(function(attr){
|
35
|
+
// Filter out stuff that we don't need
|
36
|
+
if(attr.nodeName == '_extended' || attr.nodeName == '_counted' ||
|
37
|
+
typeof attr.nodeValue == 'function' ||!Element.hasAttribute(node, attr.nodeName)) return;
|
38
|
+
// remove trailing ; in style attributes on Firefox
|
39
|
+
var value = node.readAttribute(attr.nodeName);
|
40
|
+
if(attr.nodeName == 'style' && value.endsWith(';'))
|
41
|
+
value = value.substr(0, value.length-1);
|
42
|
+
return attr.nodeName + '="' + value + '"'
|
43
|
+
}).compact().sort())).join(' ') + '>' + $A(node.childNodes).map(serializeNode).join('') +
|
44
|
+
'</' + tag + '>';
|
45
|
+
}
|
46
|
+
|
47
|
+
new Test.Unit.Runner({
|
48
|
+
|
49
|
+
setup: function() {
|
50
|
+
$('result').innerHTML = '';
|
51
|
+
},
|
52
|
+
|
53
|
+
testBuilderBasics: function() { with(this) {
|
54
|
+
var element = Builder.node('div');
|
55
|
+
assertEqual('DIV', element.nodeName);
|
56
|
+
|
57
|
+
var element = Builder.node('div',{id:'mydiv'})
|
58
|
+
assertEqual('mydiv', element.id);
|
59
|
+
|
60
|
+
var element = Builder.node('div',{id:'mydiv',className:'one two'})
|
61
|
+
assertEqual('mydiv', element.id);
|
62
|
+
assertEqual('one two', element.className);
|
63
|
+
|
64
|
+
var element = Builder.node('span','text 123 <blah>');
|
65
|
+
assertEqual('SPAN', element.nodeName);
|
66
|
+
assertEqual('text 123 <blah>', element.innerHTML);
|
67
|
+
|
68
|
+
var element = Builder.node('span',123);
|
69
|
+
assertEqual('SPAN', element.nodeName);
|
70
|
+
assertEqual('123', element.innerHTML);
|
71
|
+
|
72
|
+
var element = Builder.node('span',['test']);
|
73
|
+
assertEqual('SPAN', element.nodeName);
|
74
|
+
assertEqual('test', element.innerHTML);
|
75
|
+
|
76
|
+
var element = Builder.node('span',['test',123]);
|
77
|
+
assertEqual('SPAN', element.nodeName);
|
78
|
+
assertEqual('test123', element.innerHTML);
|
79
|
+
|
80
|
+
var element = Builder.node('span',{},['test',123]);
|
81
|
+
assertEqual('SPAN', element.nodeName);
|
82
|
+
assertEqual('test123', element.innerHTML);
|
83
|
+
|
84
|
+
var element = Builder.node('span',{id:'myspan'},['test',123]);
|
85
|
+
assertEqual('SPAN', element.nodeName);
|
86
|
+
assertEqual('myspan', element.id);
|
87
|
+
assertEqual('test123', element.innerHTML);
|
88
|
+
|
89
|
+
var element = Builder.node('div',[1,2,[3],[[[4],5],6],7,8,[[[[9]]],0]]);
|
90
|
+
assertEqual('1234567890',element.innerHTML);
|
91
|
+
|
92
|
+
var element = Builder.node('div',[1,'2',['3'],[[[4],'5'],6],7,'8',[[[['9']]],0]]);
|
93
|
+
assertEqual('1234567890',element.innerHTML);
|
94
|
+
|
95
|
+
var element = Builder.node('div',{id:'mydiv'},[1,2,[3],[[[4],5],6],7,8,[[[[9]]],0]]);
|
96
|
+
assertEqual('1234567890',element.innerHTML);
|
97
|
+
|
98
|
+
var element = Builder.node('div',{id:'mydiv'},[1,'2',['3'],[[[4],'5'],6],7,'8',[[[['9']]],0]]);
|
99
|
+
assertEqual('1234567890',element.innerHTML);
|
100
|
+
assertEqual(10, element.childNodes.length);
|
101
|
+
|
102
|
+
var element = Builder.node('div', Builder.node('span'));
|
103
|
+
assertEqual(1, element.childNodes.length);
|
104
|
+
assertEqual('SPAN', element.childNodes[0].tagName);
|
105
|
+
|
106
|
+
var element = Builder.node('div', {id:'mydiv'}, Builder.node('span'));
|
107
|
+
assertEqual(1, element.childNodes.length);
|
108
|
+
assertEqual('mydiv', element.id);
|
109
|
+
assertEqual('SPAN', element.childNodes[0].tagName);
|
110
|
+
}},
|
111
|
+
|
112
|
+
testBuilderClassAndFor: function() { with(this) {
|
113
|
+
var elt = Builder.node('div', { className: 'demoClass' });
|
114
|
+
assertEqual('demoClass', elt.className);
|
115
|
+
var elt = Builder.node('label', { htmlFor: 'mydiv' });
|
116
|
+
assertEqual('mydiv', elt.htmlFor);
|
117
|
+
}},
|
118
|
+
|
119
|
+
testBuilderExtendsElement: function() { with(this) {
|
120
|
+
assertRespondsTo('hide', Builder.node('div'));
|
121
|
+
}},
|
122
|
+
|
123
|
+
testBuilderAllXHTMLTags: function() { with(this) {
|
124
|
+
var XHTML_TAGS = [
|
125
|
+
'a','abbr','acronym','address','applet','area',
|
126
|
+
'b','bdo','big','blockquote','br','button',
|
127
|
+
'caption','cite','code','col','colgroup',
|
128
|
+
'dd','del','dfn','div','dl','dt',
|
129
|
+
'em',
|
130
|
+
'fieldset','form',
|
131
|
+
'h1','h2','h3','h4','h5','h6','hr',
|
132
|
+
'i','iframe','img','input','ins',
|
133
|
+
'kbd',
|
134
|
+
'label','legend','li',
|
135
|
+
'map',
|
136
|
+
'object','ol','optgroup','option',
|
137
|
+
'p','param','pre',
|
138
|
+
'q',
|
139
|
+
'samp','script','select','small','span','strong','style','sub','sup',
|
140
|
+
'table','tbody','td','textarea','tfoot','th','thead','tr','tt',
|
141
|
+
'ul','var']
|
142
|
+
|
143
|
+
XHTML_TAGS.each(function(tag) {
|
144
|
+
try {
|
145
|
+
var element = Builder.node(tag);
|
146
|
+
assertNotNull(element, 'Tag "'+tag+'" expected, but was null.');
|
147
|
+
assertEqual(tag.toUpperCase(), element.nodeName);
|
148
|
+
|
149
|
+
var element = Builder.node(tag,{id:'tag_'+tag+'_test_id'});
|
150
|
+
assertEqual(tag.toUpperCase(), element.nodeName);
|
151
|
+
assertEqual('tag_'+tag+'_test_id', element.id, 'Setting id attribute for "'+tag+'" failed!');
|
152
|
+
} catch(e) {
|
153
|
+
assert(false, 'Error while creating node of type '+tag+'. Note: Firefox bug in 1.0.X on option and optgroup, fixed in 1.5b1. Internet Explorer 6 doesn\'t support the ABBR tag and has no standard DOM implementation for tables.');
|
154
|
+
}
|
155
|
+
});
|
156
|
+
}},
|
157
|
+
|
158
|
+
// special case, because requires workarounds on IE and Firefox < 1.5
|
159
|
+
testBuilderOptionTag: function() { with(this) {
|
160
|
+
assertEqual('', Builder.node('option').innerHTML);
|
161
|
+
assertEqual('test', Builder.node('option','test').innerHTML);
|
162
|
+
assertEqual('', Builder.node('option',{className:'test'}).innerHTML);
|
163
|
+
assertEqual('test', Builder.node('option',{className:'test'},'test').innerHTML);
|
164
|
+
assertEqual('test', Builder.node('option',{},'test').innerHTML);
|
165
|
+
|
166
|
+
var selectElement = Builder.node('select');
|
167
|
+
var optionElement = Builder.node('option',{className:'test',id:'option_123'},123);
|
168
|
+
selectElement.appendChild(optionElement);
|
169
|
+
document.body.appendChild(selectElement);
|
170
|
+
assertEqual('123', $('option_123').innerHTML);
|
171
|
+
}},
|
172
|
+
|
173
|
+
testBuilderContatenation: function() { with(this) {
|
174
|
+
var element = Builder.node('div', [Builder.node('span')]);
|
175
|
+
assertEqual('DIV', element.nodeName);
|
176
|
+
assertEqual(1, element.childNodes.length);
|
177
|
+
assertEqual('SPAN', element.firstChild.nodeName);
|
178
|
+
|
179
|
+
var element = Builder.node('div', [Builder.node('span'),'text']);
|
180
|
+
assertEqual(2, element.childNodes.length);
|
181
|
+
assertEqual(0, element.firstChild.childNodes.length);
|
182
|
+
assertEqual('DIV', element.nodeName);
|
183
|
+
assertEqual('SPAN', element.firstChild.nodeName);
|
184
|
+
assertEqual(3, element.firstChild.nextSibling.nodeType);
|
185
|
+
|
186
|
+
var element = Builder.node('div', [Builder.node('span',[Builder.node('strong','blah')]),'text']);
|
187
|
+
assertEqual(2, element.childNodes.length);
|
188
|
+
assertEqual(1, element.firstChild.childNodes.length);
|
189
|
+
assertEqual('DIV', element.nodeName);
|
190
|
+
assertEqual('SPAN', element.firstChild.nodeName);
|
191
|
+
assertEqual('STRONG', element.firstChild.firstChild.nodeName);
|
192
|
+
assertEqual('blah', element.firstChild.firstChild.innerHTML);
|
193
|
+
assertEqual(3, element.firstChild.nextSibling.nodeType);
|
194
|
+
}},
|
195
|
+
|
196
|
+
testBuilderComplexExample: function() { with(this) {
|
197
|
+
var element = Builder.node('div',{id:'ghosttrain'},[
|
198
|
+
Builder.node('div',{style:'font-weight: bold; font-size: 11px'},[
|
199
|
+
Builder.node('h1','Ghost Train'),
|
200
|
+
"testtext", 2, 3, 4,
|
201
|
+
Builder.node('ul',[
|
202
|
+
Builder.node('li',{onclick:'alert(\'test\')'},'click me')
|
203
|
+
]),
|
204
|
+
]),
|
205
|
+
]);
|
206
|
+
assertEqual('DIV', element.nodeName);
|
207
|
+
|
208
|
+
$('result').appendChild(element);
|
209
|
+
|
210
|
+
// browsers aren't sure about upper and lower case on elements
|
211
|
+
assertEqual(
|
212
|
+
'<div id="ghosttrain"><div style="font-weight: bold; font-size: 11px">' +
|
213
|
+
'<h1>Ghost Train</h1>testtext234<ul><li onclick="alert(\'test\')">click me</li></ul></div></div>',
|
214
|
+
serializeNode($('result').childNodes[0]));
|
215
|
+
}},
|
216
|
+
|
217
|
+
testBuilderShortcuts: function() { with(this) {
|
218
|
+
Builder.dump();
|
219
|
+
|
220
|
+
var element = DIV(SPAN());
|
221
|
+
assertEqual('SPAN', element.childNodes[0].tagName);
|
222
|
+
|
223
|
+
var element = DIV({id:'test'},SPAN());
|
224
|
+
assertEqual('SPAN', element.childNodes[0].tagName);
|
225
|
+
|
226
|
+
var element = DIV({id:'ghosttrain'},[
|
227
|
+
DIV({style:'font-weight: bold; font-size: 11px'},[
|
228
|
+
H1('Ghost Train'),
|
229
|
+
"testtext", 2, 3, 4,
|
230
|
+
UL([
|
231
|
+
LI({onclick:'alert(\'test\')'},'click me')
|
232
|
+
]),
|
233
|
+
]),
|
234
|
+
]);
|
235
|
+
assertEqual('DIV', element.nodeName);
|
236
|
+
|
237
|
+
$('result').appendChild(element);
|
238
|
+
|
239
|
+
assertEqual(
|
240
|
+
'<div id="ghosttrain"><div style="font-weight: bold; font-size: 11px">' +
|
241
|
+
'<h1>Ghost Train</h1>testtext234<ul><li onclick="alert(\'test\')">click me</li></ul></div></div>',
|
242
|
+
serializeNode($('result').childNodes[0]));
|
243
|
+
}},
|
244
|
+
|
245
|
+
testBuilderBuild: function() { with(this) {
|
246
|
+
['<span>this is <b>neat!</b></span>',' \n<span>this is <b>neat!</b></span>\n '].each(
|
247
|
+
function(html){
|
248
|
+
var node = Builder.build(html);
|
249
|
+
assertEqual('<span>this is <b>neat!</b></span>', serializeNode(node));
|
250
|
+
});
|
251
|
+
}},
|
252
|
+
|
253
|
+
testBuilderAttributeEscaping: function() { with(this) {
|
254
|
+
var element = Builder.node('div',{blah:"<foo'bar&baz\"bat>"});
|
255
|
+
assertEqual("<foo'bar&baz\"bat>", $(element).readAttribute('blah'));
|
256
|
+
}}
|
257
|
+
|
258
|
+
});
|
259
|
+
// ]]>
|
260
|
+
</script>
|
261
|
+
</body>
|
262
|
+
</html>
|
@@ -0,0 +1,131 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<title>script.aculo.us Unit test file</title>
|
6
|
+
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
7
|
+
<script src="assets/prototype.js" type="text/javascript"></script>
|
8
|
+
<script src="assets/scriptaculous.js" type="text/javascript"></script>
|
9
|
+
<script src="assets/unittest.js" type="text/javascript"></script>
|
10
|
+
<link rel="stylesheet" href="../test.css" type="text/css" />
|
11
|
+
<style type="text/css" media="screen">
|
12
|
+
/* <![CDATA[ */
|
13
|
+
#div_absolute_test { position: absolute }
|
14
|
+
/* ]]> */
|
15
|
+
</style>
|
16
|
+
|
17
|
+
</head>
|
18
|
+
<body>
|
19
|
+
<h1>script.aculo.us Unit test file</h1>
|
20
|
+
<p>
|
21
|
+
Test of drag & drop functions in dragdrop.js
|
22
|
+
</p>
|
23
|
+
|
24
|
+
<!-- Log output -->
|
25
|
+
<div id="testlog"> </div>
|
26
|
+
|
27
|
+
<p id="p_test">p_test</p>
|
28
|
+
<p id="p_test2">p_test2</p>
|
29
|
+
<p id="p_test3">p_test3</p>
|
30
|
+
<img id="img_test" src="icon.png" alt="img_text"/>
|
31
|
+
<div id="droppable_test">droppable_test</div>
|
32
|
+
|
33
|
+
<div id="div_test">div_test</div>
|
34
|
+
<div id="div_absolute_test">div_absolute_test</div>
|
35
|
+
<div id="div_absolute_inline_test" style="position:absolute">div_absolute_inline_test</div>
|
36
|
+
|
37
|
+
<div id="droppable_container">
|
38
|
+
<div id="d1">droppable_test</div>
|
39
|
+
<div id="d2">droppable_test</div>
|
40
|
+
</div>
|
41
|
+
|
42
|
+
<div id="droppable_container_2">
|
43
|
+
<div id="d3">droppable_test</div>
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<!-- Tests follow -->
|
47
|
+
<script type="text/javascript" language="javascript" charset="utf-8">
|
48
|
+
// <![CDATA[
|
49
|
+
|
50
|
+
new Test.Unit.Runner({
|
51
|
+
|
52
|
+
testDraggableBasics: function() { with(this) {
|
53
|
+
var d = new Draggable('p_test');
|
54
|
+
assertInstanceOf(Draggable, d);
|
55
|
+
}},
|
56
|
+
|
57
|
+
testDraggableStartEffect: function() { with(this) {
|
58
|
+
var d = new Draggable('p_test2');
|
59
|
+
assert(d.options.starteffect, 'There should be a default start effect.');
|
60
|
+
d = new Draggable('p_test3', { endeffect: Prototype.EmptyFunction });
|
61
|
+
assert(undefined === d.options.startEffect, 'There should be no default start effect.');
|
62
|
+
}},
|
63
|
+
|
64
|
+
testAutoPositioning: function() { with(this) {
|
65
|
+
assertEqual('static', Element.getStyle('div_test','position'));
|
66
|
+
new Draggable('div_test');
|
67
|
+
new Draggable('div_absolute_test');
|
68
|
+
new Draggable('div_absolute_inline_test');
|
69
|
+
assertEqual('relative', Element.getStyle('div_test','position'));
|
70
|
+
assertEqual('absolute', Element.getStyle('div_absolute_test','position'));
|
71
|
+
assertEqual('absolute', Element.getStyle('div_absolute_inline_test','position'));
|
72
|
+
}},
|
73
|
+
|
74
|
+
testDroppbalesBasics: function() { with(this) {
|
75
|
+
assertEqual(0, Droppables.drops.length);
|
76
|
+
assertEqual('static', Element.getStyle('droppable_test','position'));
|
77
|
+
|
78
|
+
Droppables.add('droppable_test');
|
79
|
+
assertEqual(1, Droppables.drops.length);
|
80
|
+
assertEqual('relative', Element.getStyle('droppable_test','position'));
|
81
|
+
|
82
|
+
Droppables.remove('droppable_test');
|
83
|
+
assertEqual(0, Droppables.drops.length);
|
84
|
+
|
85
|
+
// accept option should take strings or array of strings
|
86
|
+
Droppables.add('droppable_test',{accept:'document'});
|
87
|
+
assertEqual(['document'].inspect(), Droppables.drops[0].accept.inspect());
|
88
|
+
Droppables.remove('droppable_test');
|
89
|
+
|
90
|
+
Droppables.add('droppable_test',{accept:['document','image']});
|
91
|
+
assertEqual(['document','image'].inspect(), Droppables.drops[0].accept.inspect());
|
92
|
+
Droppables.remove('droppable_test');
|
93
|
+
}},
|
94
|
+
|
95
|
+
testDroppableContainment: function() { with(this) {
|
96
|
+
// Droppable containers should be cached
|
97
|
+
Droppables.add('droppable_test', {
|
98
|
+
containment:'droppable_container' });
|
99
|
+
assertEqual(1, Droppables.drops[0]._containers.length);
|
100
|
+
assertEqual($('droppable_container'), Droppables.drops[0]._containers[0]);
|
101
|
+
assert(Droppables.isContained($('d1'), Droppables.drops[0]));
|
102
|
+
assert(Droppables.isContained($('d2'), Droppables.drops[0]));
|
103
|
+
assert(!Droppables.isContained($('d3'), Droppables.drops[0]));
|
104
|
+
Droppables.remove('droppable_test');
|
105
|
+
|
106
|
+
Droppables.add('droppable_test', {
|
107
|
+
containment:['droppable_container','droppable_container_2'] });
|
108
|
+
assertEqual(2, Droppables.drops[0]._containers.length);
|
109
|
+
assertEqual($('droppable_container'), Droppables.drops[0]._containers[0]);
|
110
|
+
assertEqual($('droppable_container_2'), Droppables.drops[0]._containers[1]);
|
111
|
+
assert(Droppables.isContained($('d1'), Droppables.drops[0]));
|
112
|
+
assert(Droppables.isContained($('d2'), Droppables.drops[0]));
|
113
|
+
assert(Droppables.isContained($('d3'), Droppables.drops[0]));
|
114
|
+
Droppables.remove('droppable_test');
|
115
|
+
}},
|
116
|
+
|
117
|
+
testDroppablesIsAffected: function() { with(this) {
|
118
|
+
Droppables.add('droppable_test');
|
119
|
+
|
120
|
+
Position.prepare();
|
121
|
+
assert(!Droppables.isAffected([-10, -10], null, Droppables.drops[0]));
|
122
|
+
|
123
|
+
var p = Position.page($('droppable_test'));
|
124
|
+
assert(Droppables.isAffected(p, null, Droppables.drops[0]));
|
125
|
+
}}
|
126
|
+
|
127
|
+
}, "testlog");
|
128
|
+
// ]]>
|
129
|
+
</script>
|
130
|
+
</body>
|
131
|
+
</html>
|