Permalink
Browse files

added a basic QUnit test suite

  • Loading branch information...
1 parent 78c9f74 commit ef8ca9a3c0fe9b08caaf0fc3ecad3b765624415d @danielstocks committed Jun 28, 2010
Showing with 74 additions and 0 deletions.
  1. +51 −0 test/test.html
  2. +23 −0 test/test.js
View
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <link rel="stylesheet" href="http://github.com/jquery/qunit/raw/master/qunit/qunit.css">
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
+ <script src="http://github.com/jquery/qunit/raw/master/qunit/qunit.js"></script>
+ <script src="../jquery.cookie.js"></script>
+ <script src="../jquery.collapse.js"></script>
+ <script src="test.js"></script>
+</head>
+<body>
+ <h1 id="qunit-header">jQuery.Collapse</h1>
+ <h2 id="qunit-banner"></h2>
+ <h2 id="qunit-userAgent"></h2>
+ <ol id="qunit-tests"></ol>
+ <div id="main" style="position:absolute; left:-100000px">
+ <div class="test">
+ <h3><a href="#">Fruits</a></h3>
+ <ul>
+ <li>Apple</li>
+ <li>Pear</li>
+ <li>Orange</li>
+ </ul>
+ <h3><a href="#">Vegetables</a></h3>
+ <ul>
+ <li>Carrot</li>
+ <li>Tomato</li>
+ <li>Squash</li>
+ </ul>
+ </div>
+ <div class="test">
+ <h3><a href="#">Colours</a></h3>
+ <ul>
+ <li>Green</li>
+ <li>Yellow</li>
+ <li>Orange</li>
+ </ul>
+ </div>
+ <div class="test-2">
+ <h3><a href="#">Countries</a></h3>
+ <ul>
+ <li>Sweden</li>
+ <li>Jamaica</li>
+ <li>India</li>
+ <li>Australia</li>
+ <li>Brazil</li>
+ </ul>
+ </div>
+ </div>
+</body>
+</html>
View
@@ -0,0 +1,23 @@
+$(document).ready(function() {
+
+ // Some sample Markup
+ var el = $("#main .test").collapse({disableCookie : true});
+ var headings = el.find("h3");
+ var lists = el.find("ul");
+ var first_list = $(lists[0]);
+
+ // Simple Test
+ module("Collapse");
+ test("basic", function() {
+
+ // Make sure lists are hidden per default
+ equals(headings.filter(".inactive").length, 3, "Three inactive headings");
+ equals(el.find("ul:hidden").length, 3, "Three hidden lists");
+
+ // Trigger show
+ el.trigger('show', [first_list]);
+ ok(first_list.is(":visible"), "First list is visible");
+ equals(el.find("ul:hidden").length, 2, "Two lists are left hidden");
+
+ });
+});

0 comments on commit ef8ca9a

Please sign in to comment.