]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
tests: revert to systematic test of magellan graceful failure
authorNicolas Coden <nicolas@ncoden.fr>
Sun, 4 Mar 2018 22:50:05 +0000 (23:50 +0100)
committerNicolas Coden <nicolas@ncoden.fr>
Sun, 4 Mar 2018 22:50:05 +0000 (23:50 +0100)
Partially revert e89d85cbf4328c8d925a64bde7e2525c88841d5a

Test Magellan.scrollToLoc systematically as it should _never_ throw an error when target does not exists.

test/javascript/components/magellan.js

index 37713356ec3a1676de34b8cabb01384c466d794a..8e70b727f2227d5c3023fcd992a6ac8534eb1e79 100644 (file)
@@ -1,6 +1,6 @@
 describe('Magellan', function() {
        var plugin;
-       var $html, $content;    
+       var $html, $content;
 
   var generateUl = function(count) {
        var html = '';
@@ -68,7 +68,7 @@ describe('Magellan', function() {
     });
 
 
-    it('fails gracefully when target does not exist', function(done) {
+    it('fails gracefully when target does not exist', function() {
        var count = 5, duration = 200;
       $html = $(generateUl(count)).appendTo('body');
       $content = $(generateContent(count - 1)).appendTo('body');
@@ -78,19 +78,16 @@ describe('Magellan', function() {
 
       var hasError = false;
       var targets = $html.find('a');
-      if(targets.length){
+      try {
         var target = $(targets).eq(-1).attr('href');
         plugin.scrollToLoc(target);
-        hasError.should.equal(false);
-        done();
-                       } else {
+      }
+      catch (err) {
         hasError = true;
-        hasError.should.equal(false);
-        done();
-                       }
-      
+      }
+      hasError.should.equal(false);
     });
 
   });
 
-});
\ No newline at end of file
+});