Benoît Hubert 8 éve
szülő
commit
8146357cfb
1 módosított fájl, 32 hozzáadás és 0 törlés
  1. 32 0
      js/test/ws.test.js

+ 32 - 0
js/test/ws.test.js

@@ -1,7 +1,39 @@
+function timeoutAsync(cb, delay) {
+  return new Promise((resolve, reject) => {
+    setTimeout(function() {
+      cb();
+      resolve(true);
+    }, delay);
+  });
+}
+
 (function($) {
   $(document).ready(function() {
+
+    var $mainMenu = $('#nav-menus');
+    var $menuBtn = $('#menu-btn');
+
     QUnit.test( "hello test", function( assert ) {
       assert.ok( 1 == "1", "Passed!" );
     });
+
+    QUnit.test( "test menu toggle", function( assert ) {
+      var done = assert.async();
+      assert.equal( $mainMenu.width(), 0 );
+      $menuBtn.trigger('click');
+      assert.ok( $mainMenu.hasClass('in') );
+      assert.ok( $mainMenu.is(':visible') );
+      timeoutAsync(() => {
+        assert.notEqual( $mainMenu.width(), 0 );
+        $menuBtn.trigger('click');
+        assert.ok( ! $mainMenu.hasClass('in') );
+      }, 100)
+      .then(() => timeoutAsync(() => {
+        assert.equal( $mainMenu.width(), 0 );
+        done();
+      }, 160));
+    });
+
+
   });
 })(jQuery);