1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
<html id="html">
<head>
<script type="text/javascript" src="../lib/Test/Builder.js"></script>
<script type="text/javascript" src="../lib/Test/More.js"></script>
<script type="text/javascript" src="../lib/test.js"></script>
<script type="text/javascript" src="../../jquery/jquery-svn.js"></script>
</head>
<body id="body">
<h1>Basic Usage</h1>
<!-- Test HTML -->
<div id="main" style="display: none;"></div>
<div id="foo" style="display: none;"></div>
<pre id="test"><script>
plan({tests: 11});
var div = $("div");
diag( "Getters" );
cmpOK( div.size(), "==", 2, "Get Number of Elements Found" );
isSet( div.get(), q("main","foo"), "Get All Elements" );
cmpOK( div.get(0), "==", document.getElementById("main"),
"Get A Single Element" );
diag( "Setters" );
div.each(function(){this.foo = 'zoo';});
var pass = true;
for ( var i = 0; i < div.size(); i++ ) {
if ( div.get(i).foo != "zoo" ) pass = false;
}
ok( pass, "Execute, Relative" );
div.addClass("test");
var pass = true;
for ( var i = 0; i < div.size(); i++ ) {
if ( div.get(i).className.indexOf("test") == -1 ) pass = false;
}
ok( pass, "Add Class" );
div.removeClass("test");
var pass = true;
for ( var i = 0; i < div.size(); i++ ) {
if ( div.get(i).className.indexOf("test") != -1 ) pass = false;
}
ok( pass, "Remove Class" );
div.html("<b>test</b>");
var pass = true;
for ( var i = 0; i < div.size(); i++ ) {
if ( div.get(i).childNodes.length == 0 ) pass = false;
}
ok( pass, "Set HTML" );
div.attr("foo", "bar");
var pass = true;
for ( var i = 0; i < div.size(); i++ ) {
if ( div.get(i).foo != "bar" ) pass = false;
}
ok( pass, "Set Attribute" );
div.attr({foo: 'baz', zoo: 'ping'});
var pass = true;
for ( var i = 0; i < div.size(); i++ ) {
if ( div.get(i).foo != "baz" && div.get(i).zoo != "ping" ) pass = false;
}
ok( pass, "Set Multiple Attributes" );
diag( "Effects" );
var pass = true;
div.show().each(function(){
if ( this.style.display == "none" ) pass = false;
});
ok( pass, "Show" );
var pass = true;
div.hide().each(function(){
if ( this.style.display != "none" ) pass = false;
});
ok( pass, "Hide" );
</script></pre>
</body>
</html>
|