Home page Forum Wiki Mail Jabber Devel NIX-FILES

AltLUG Git

Git-repositories of Altai Linux User Group

Merge remote branch 'wwalser/recursionBug'
[qunit.git] / test / test.js
index 91934a9..356204b 100644 (file)
@@ -469,3 +469,65 @@ test("let teardown clean up globals", function() {
        // this test will always pass if run without ?noglobals=true
        window.badGlobalVariableIntroducedInTest = true;
 });
+
+if (typeof setTimeout !== 'undefined') {
+function testAfterDone(){
+       var testName = "ensure has correct number of assertions";
+
+       function secondAfterDoneTest(){
+               QUnit.config.done = [];
+               //QUnit.done = function(){};
+               //because when this does happen, the assertion count parameter doesn't actually 
+               //work we use this test to check the assertion count.
+               module("check previous test's assertion counts");
+               test('count previous two test\'s assertions', function(){
+                       var spans = document.getElementsByTagName('span'),
+                       tests = [],
+                       countNodes;
+               
+                       //find these two tests
+                       for (var i = 0; i < spans.length; i++) {
+                               if (spans[i].innerHTML.indexOf(testName) !== -1) {
+                                       tests.push(spans[i]);
+                               }
+                       }
+               
+                       //walk dom to counts
+                       countNodes = tests[0].nextSibling.nextSibling.getElementsByTagName('b');
+                       equal(countNodes[1].innerHTML, "99");
+                       countNodes = tests[1].nextSibling.nextSibling.getElementsByTagName('b');
+                       equal(countNodes[1].innerHTML, "99");
+               });
+       }
+       QUnit.config.done = [];
+       QUnit.done(secondAfterDoneTest);
+       
+       module("Synchronous test after load of page");
+
+       asyncTest('Async test', function(){
+               start();
+               for (i=1;i<100;i++) {
+                       ok(i);
+               }
+       });
+               
+       test(testName, 99, function(){
+               for (i=1;i<100;i++) {
+                       ok(i);
+               }
+       });
+       
+       //we need two of these types of tests in order to ensure that assertions
+       //don't move between tests.
+       test(testName + ' 2', 99, function(){
+               for (i=1;i<100;i++) {
+                       ok(i);
+               }
+       });
+       
+
+}
+
+QUnit.done(testAfterDone);
+
+}

Hosting is provided AltSPAHow to use Git
Please direct any questions on jabber alex.wolf@jabber.ru

Valid HTML 4.0 Transitional Valid CSS!

Designer Alexander Wolf