diff options
author | John Resig <jeresig@gmail.com> | 2006-08-14 01:47:47 +0000 |
---|---|---|
committer | John Resig <jeresig@gmail.com> | 2006-08-14 01:47:47 +0000 |
commit | 76ac10ed1f53d5166e18461e0d1bb98ceabe1e84 (patch) | |
tree | 6f73169d9bb3aa70749e566d70633823058c05f3 | |
parent | 7448c61ee2199f6f7002e33e533cebc42b000c89 (diff) | |
download | jquery-76ac10ed1f53d5166e18461e0d1bb98ceabe1e84.tar.gz jquery-76ac10ed1f53d5166e18461e0d1bb98ceabe1e84.zip |
Added additional changes to the test suite.
-rw-r--r-- | build/test/test.js | 38 | ||||
-rw-r--r-- | build/test/tests/basic.html | 86 | ||||
-rw-r--r-- | build/test/tests/css1.html | 57 | ||||
-rw-r--r-- | build/test/tests/css2.html | 66 | ||||
-rw-r--r-- | build/test/tests/css3.html | 79 | ||||
-rw-r--r-- | build/test/tests/custom.html | 66 | ||||
-rw-r--r-- | build/test/tests/prereq.html | 30 | ||||
-rw-r--r-- | build/test/tests/xpath.html | 71 |
8 files changed, 38 insertions, 455 deletions
diff --git a/build/test/test.js b/build/test/test.js new file mode 100644 index 000000000..453eb5db7 --- /dev/null +++ b/build/test/test.js @@ -0,0 +1,38 @@ +load( "build/js/writeFile.js", "build/js/parse.js" ); + +var dir = arguments[1]; + +var indexFile = readFile( "build/test/index.html" ); +var testFile = readFile( "build/test/test.html" ); +var files = {}; + +var jq = parse( readFile( arguments[0] ) ); + +for ( var i = 0; i < jq.length; i++ ) { + if ( jq[i].tests.length > 0 ) { + + var count = 1; + while ( files[ jq[i].name + count ] ) { count++; } + var name = jq[i].name + count; + + var myFile = testFile + .replace( /{TITLE}/g, jq[i].name ) + .replace( /{NUM}/g, jq[i].tests.length ) + .replace( /{TESTS}/g, jq[i].tests.join("\n") ); + + var fileName = "tests/" + name + ".js"; + + //writeFile( dir + "/" + fileName, myFile ); + writeFile( dir + "/" + fileName, jq[i].tests.join("\n") ); + + files[ fileName ] = 1; + } +} + +var fileString = ""; +for ( var i in files ) { + if ( fileString ) fileString += ", "; + fileString += "'" + i + "'"; +} + +writeFile( dir + "/index.html", indexFile.replace( /{FILES}/g, fileString ) ); diff --git a/build/test/tests/basic.html b/build/test/tests/basic.html deleted file mode 100644 index 9710083d1..000000000 --- a/build/test/tests/basic.html +++ /dev/null @@ -1,86 +0,0 @@ -<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> diff --git a/build/test/tests/css1.html b/build/test/tests/css1.html deleted file mode 100644 index 014fe4fb1..000000000 --- a/build/test/tests/css1.html +++ /dev/null @@ -1,57 +0,0 @@ -<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>CSS 1 Selectors</h1> - - <!-- Test HTML --> - <div id="main" style="display: none;"> - <p id="first">See <a id="simon1" href="http://simon.incutio.com/archive/2003/03/25/#getElementsBySelector" rel="bookmark">this blog entry</a> - for more information.</p><p>Here are some links in a normal paragraph: - <a id="google" href="http://www.google.com/" title="Google!">Google</a>, - <a id="groups" href="http://groups.google.com/">Google Groups</a>. - This link has <code><a href="#" id="anchor1">class="blog"</a></code>: - <a href="http://diveintomark.org/" class="blog" hreflang="en" id="mark">diveintomark</a></p> - <div id="foo"><p>Everything inside the red border is inside a div with - <code>id="foo"</code>.</p><p lang="en">This is a normal link: - <a id="yahoo"href="http://www.yahoo.com/">Yahoo</a></p> - <p>This link has <code><a href="#2" id="anchor2">class="blog"</a></code>: - <a href="http://simon.incutio.com/" class="blog link" id="simon">Simon Willison's Weblog</a></p></div> - <p>Try them out: </p> - <ul id="first"></ul> - </div> - - <pre id="test"><script> - plan({tests: 16}); - - t( "Element Selector", "div", ["main","foo"] ); - t( "Element Selector", "body", ["body"] ); - t( "Element Selector", "html", ["html"] ); - cmpOK( $("*").size(), ">=", 30, "Element Selector" ); - t( "Parent Element", "div div", ["foo"] ); - - t( "ID Selector", "#body", ["body"] ); - t( "ID Selector w/ Element", "body#body", ["body"] ); - cmpOK($("ul#first").get(0), "==", document.getElementsByTagName("ul")[0], - "ID Selector w/ Element"); - - t( "Class Selector", ".blog", ["simon","mark"] ); - t( "Class Selector", ".blog.link", ["simon"] ); - t( "Class Selector w/ Element", "a.blog", ["simon","mark"] ); - t( "Parent Class Selector", "p .blog", ["simon","mark"] ); - - t( "Comma Support", "a.blog, div", - ["main","foo","simon","mark"] ); - t( "Comma Support", "a.blog , div", - ["main","foo","simon","mark"] ); - t( "Comma Support", "a.blog ,div", - ["main","foo","simon","mark"] ); - t( "Comma Support", "a.blog,div", - ["main","foo","simon","mark"] ); - </script></pre> -</body> -</html> diff --git a/build/test/tests/css2.html b/build/test/tests/css2.html deleted file mode 100644 index 5f19308c5..000000000 --- a/build/test/tests/css2.html +++ /dev/null @@ -1,66 +0,0 @@ -<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>CSS 2 Selectors</h1> - - <!-- Test HTML --> - <div id="main" style="display: none;"> - <p id="firstp">See <a id="simon1" href="http://simon.incutio.com/archive/2003/03/25/#getElementsBySelector" rel="bookmark">this blog entry</a> - for more information.</p> - <p id="ap">Here are some links in a normal paragraph: - <a id="google" href="http://www.google.com/" title="Google!">Google</a>, - <a id="groups" href="http://groups.google.com/">Google Groups</a>. - This link has <code><a href="#" id="anchor1">class="blog"</a></code>: - <a href="http://diveintomark.org/" class="blog" hreflang="en" id="mark">diveintomark</a></p> - <div id="foo"><p id="sndp">Everything inside the red border is inside a div with - <code>id="foo"</code>.</p><p lang="en" id="en">This is a normal link: - <a id="yahoo" href="http://www.yahoo.com/" class="blogTest">Yahoo</a></p> - <p id="sap">This link has <code><a href="#2" id="anchor2">class="blog"</a></code>: - <a href="http://simon.incutio.com/" class="blog link" id="simon" rel="bookmark link">Simon Willison's Weblog</a></p></div> - <p id="first">Try them out: </p> - <ul id="first"></ul> - </div> - <pre id="test"><script> - plan({tests: 20}); - - t( "Child", "p > a", - ["simon1","google","groups","mark","yahoo","simon"] ); - t( "Child", "p> a", - ["simon1","google","groups","mark","yahoo","simon"] ); - t( "Child", "p >a", - ["simon1","google","groups","mark","yahoo","simon"] ); - t( "Child", "p>a", - ["simon1","google","groups","mark","yahoo","simon"] ); - t( "Child w/ Class", "p > a.blog", - ["mark","simon"] ); - t( "All Children", "code > *", - ["anchor1","anchor2"] ); - t( "All Grandchildren", "p > * > *", - ["anchor1","anchor2"] ); - - t( "Adjacent", "a + a", ["groups"] ); - t( "Adjacent", "a +a", ["groups"] ); - t( "Adjacent", "a+ a", ["groups"] ); - t( "Adjacent", "a+a", ["groups"] ); - t( "Adjacent", "p + p", ["ap","en","sap"] ); - - t( "Comma, Child, and Adjacent", "a + a, code > a", - ["anchor1","anchor2","groups"] ); - - t( "First Child", "p:first-child", ["firstp","sndp"] ); - - diag( "Note: @ is used for XPath compatability" ); - t( "Attribute Exists", "a[@title]", ["google"] ); - t( "Attribute Exists", "*[@title]", ["google"] ); - t( "Attribute Exists", "[@title]", ["google"] ); - t( "Attribute Equals", "a[@rel='bookmark']", ["simon1"] ); - t( "Attribute Equals", 'a[@rel="bookmark"]', ["simon1"] ); - t( "Attribute Equals", "a[@rel=bookmark]", ["simon1"] ); - </script></pre> -</body> -</html> diff --git a/build/test/tests/css3.html b/build/test/tests/css3.html deleted file mode 100644 index ced1f9ca7..000000000 --- a/build/test/tests/css3.html +++ /dev/null @@ -1,79 +0,0 @@ -<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>CSS 3 Selectors</h1> - - <!-- Test HTML --> - <div id="main" style="display: none;"> - <p id="firstp">See <a id="simon1" href="http://simon.incutio.com/archive/2003/03/25/#getElementsBySelector" rel="bookmark">this blog entry</a> for more information.</p> - <p id="ap"> - Here are some links in a normal paragraph: <a id="google" href="http://www.google.com/" title="Google!">Google</a>, - <a id="groups" href="http://groups.google.com/">Google Groups</a>. - This link has <code><a href="#" id="anchor1">class="blog"</a></code>: - <a href="http://diveintomark.org/" class="blog" hreflang="en" id="mark">diveintomark</a> - </p> - <div id="foo"> - <p id="sndp">Everything inside the red border is inside a div with - <code>id="foo"</code>.</p> - <p lang="en" id="en">This is a normal link: - <a id="yahoo" href="http://www.yahoo.com/" class="blogTest">Yahoo</a></p> - <p id="sap">This link has <code><a href="#2" id="anchor2">class="blog"</a></code>: - <a href="http://simon.incutio.com/" class="blog link" id="simon">Simon Willison's Weblog</a></p> - </div> - <p id="first">Try them out: </p> - <ul id="first"></ul> - <ol id="empty"></ol> - <form> - <input type="text" value="Test" id="text1"/> - <input type="text" value="Test" id="text2" disabled="disabled"/> - <input type="radio" name="radio1" id="radio1"/> - <input type="radio" name="radio2" id="radio2" checked/> - <input type="checkbox" name="check" id="check1" checked/> - <input type="checkbox" name="check" id="check2"/> - </form> - </div> - - <pre id="test"><script> - plan({tests: 14}); - - t( "Attribute Begins With", "a[@href ^= 'http://www']", - ["google","yahoo"] ); - t( "Attribute Ends With", "a[@href $= 'org/']", - ["mark"] ); - t( "Attribute Contains", "a[@href *= 'google']", - ["google","groups"] ); - - t( "First Child", "p:first-child", - ["firstp","sndp"] ); - t( "Last Child", "p:last-child", - ["sap"] ); - - t( "Only Child", "a:only-child", - ["simon1","anchor1","anchor2","yahoo"] ); - - t( "Empty", "ol:empty", ["empty"] ); - - t( "Enabled UI Element", "input:enabled", - ["text1","radio1","radio2","check1","check2"] ); - t( "Disabled UI Element", "input:disabled", - ["text2"] ); - - t( "Checked UI Element", "input:checked", - ["radio2","check1"] ); - - t( "Text Contains", "a:contains('Google')", - ["google","groups"] ); - t( "Text Contains", "a:contains('Google Groups')", - ["groups"] ); - - t( "Element Preceded By", "p ~ div", ["foo"] ); - - t( "Not", "a.blog:not(.link)", ["mark"] ); - </script></pre> -</body> -</html> diff --git a/build/test/tests/custom.html b/build/test/tests/custom.html deleted file mode 100644 index 8341a2f80..000000000 --- a/build/test/tests/custom.html +++ /dev/null @@ -1,66 +0,0 @@ -<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>Custom Expressions</h1> - - <!-- Test HTML --> - <div id="main" style="display: none;"> - <p id="firstp">See <a id="simon1" href="http://simon.incutio.com/archive/2003/03/25/#getElementsBySelector" rel="bookmark">this blog entry</a> - for more information.</p> - <p id="ap">Here are some links in a normal paragraph: - <a id="google" href="http://www.google.com/" title="Google!">Google</a>, - <a id="groups" href="http://groups.google.com/">Google Groups</a>. - This link has <code><a href="#" id="anchor1">class="blog"</a></code>: - <a href="http://diveintomark.org/" class="blog" hreflang="en" id="mark">diveintomark</a> - </p> - <div id="foo"> - <p id="sndp">Everything inside the red border is inside a div with - <code>id="foo"</code>.</p> - <p lang="en" id="en">This is a normal link: - <a id="yahoo" href="http://www.yahoo.com/" class="blogTest">Yahoo</a></p> - <p id="sap">This link has <code><a href="#2" id="anchor2">class="blog"</a></code>: - <a href="http://simon.incutio.com/" class="blog link" id="simon">Simon Willison's Weblog</a></p> - </div> - <p id="first">Try them out: </p> - <ol id="empty"></ol> - <form id="form"> - <input type="hidden" value="Test" id="hidden"/> - <input type="text" value="Test" id="text1" style="display:none;"/> - <input type="text" value="Test" id="text2" disabled="disabled"/> - <input type="radio" name="radio1" id="radio1"/> - <input type="radio" name="radio2" id="radio2" checked/> - <input type="checkbox" name="check" id="check1" checked/> - <input type="checkbox" name="check" id="check2" style="visibility:hidden;"/> - </form> - </div> - - <pre id="test"><script> - plan({tests: 11}); - - t( "nth Element", "p:nth(1)", ["ap"] ); - t( "First Element", "p:first", ["firstp"] ); - t( "Last Element", "p:last", ["first"] ); - t( "Even Elements", "p:even", ["firstp","sndp","sap"] ); - t( "Odd Elements", "p:odd", ["ap","en","first"] ); - - t( "Position Equals", "p:eq(1)", ["ap"] ); - t( "Position Greater Than", "p:gt(0)", - ["ap","sndp","en","sap","first"] ); - t( "Position Less Than", "p:lt(3)", - ["firstp","ap","sndp"] ); - - t( "Is A Parent", "p:parent", - ["firstp","ap","sndp","en","sap","first"] ); - - t( "Is Visible", "input:visible", - ["text2","radio1","radio2","check1"] ); - t( "Is Hidden", "input:hidden", - ["hidden","text1","check2"] ); - </script></pre> -</body> -</html> diff --git a/build/test/tests/prereq.html b/build/test/tests/prereq.html deleted file mode 100644 index e73f19b90..000000000 --- a/build/test/tests/prereq.html +++ /dev/null @@ -1,30 +0,0 @@ -<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>Test for Prerequisites</h1> - - <pre id="test"><script> - plan({tests: 11}); - - ok( Array.prototype.push, "Array.push()" ); - ok( Function.prototype.apply, "Function.apply()" ); - ok( document.getElementById, "getElementById" ); - ok( document.getElementsByTagName, "getElementsByTagName" ); - ok( RegExp, "RegExp" ); - - ok( jQuery, "jQuery" ); - ok( $, "$()" ); - - ok( $.find, "Select" ); - ok( $.filter, "filter()" ); - - ok( $.event.add, "addEvent" ); - ok( $.event.remove, "removeEvent" ); - </script></pre> -</body> -</html> diff --git a/build/test/tests/xpath.html b/build/test/tests/xpath.html deleted file mode 100644 index 483f89692..000000000 --- a/build/test/tests/xpath.html +++ /dev/null @@ -1,71 +0,0 @@ -<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>XPath Expressions</h1> - - <!-- Test HTML --> - <div id="main" style="display: none;"> - <p id="firstp">See <a id="simon1" href="http://simon.incutio.com/archive/2003/03/25/#getElementsBySelector" rel="bookmark">this blog entry</a> - for more information.</p> - <p id="ap">Here are some links in a normal paragraph: - <a id="google" href="http://www.google.com/" title="Google!">Google</a>, - <a id="groups" href="http://groups.google.com/">Google Groups</a>. - This link has <code><a href="#" id="anchor1">class="blog"</a></code>: - <a href="http://diveintomark.org/" class="blog" hreflang="en" id="mark">diveintomark</a> - </p> - <div id="foo"> - <p id="sndp">Everything inside the red border is inside a div with - <code>id="foo"</code>.</p> - <p lang="en" id="en">This is a normal link: - <a id="yahoo" href="http://www.yahoo.com/" class="blogTest">Yahoo</a> - </p> - <p id="sap">This link has <code><a href="#2" id="anchor2">class="blog"</a></code>: - <a href="http://simon.incutio.com/" class="blog link" id="simon">Simon Willison's Weblog</a> - </p> - </div> - <p id="first">Try them out: </p> - <ol id="empty"></ol> - <form id="form"> - <input type="text" value="Test" id="text1"/> - <input type="text" value="Test" id="text2" disabled="disabled"/> - <input type="radio" name="radio1" id="radio1"/> - <input type="radio" name="radio2" id="radio2" checked/> - <input type="checkbox" name="check" id="check1" checked/> - <input type="checkbox" name="check" id="check2"/> - </form> - </div> - - <pre id="test"><script> - plan({tests: 14}); - - cmpOK( $.find("//*").length, ">=", 30, "All Elements (//*)" ); - t( "All Div Elements", "//div", ["main","foo"] ); - - t( "Absolute Path", "/html/body", ["body"] ); - t( "Absolute Path w/ *", "/*/body", ["body"] ); - t( "Long Absolute Path", "/html/body/div/div/p", ["sndp","en","sap"] ); - - t( "Absolute and Relative Paths", "/html//div", ["main","foo"] ); - - t( "All Children, Explicit", "//code/*", ["anchor1","anchor2"] ); - t( "All Children, Implicit", "//code/", ["anchor1","anchor2"] ); - - t( "Attribute Exists", "//a[@title]", ["google"] ); - t( "Attribute Equals", "//a[@rel='bookmark']", ["simon1"] ); - - t( "Parent Axis", "//p/..", ["main","foo"] ); - t( "Sibling Axis", "//p/../", - ["firstp","ap","foo","first","empty","form","sndp","en","sap"] ); - t( "Sibling Axis", "//p/../*", - ["firstp","ap","foo","first","empty","form","sndp","en","sap"] ); - - t( "Has Children", "//p[a]", - ["firstp","ap","en","sap"] ); - </script></pre> -</body> -</html> |