|
@@ -1,7 +1,39 @@
|
|
|
|
|
+function timeoutAsync(cb, delay) {
|
|
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
|
|
+ setTimeout(function() {
|
|
|
|
|
+ cb();
|
|
|
|
|
+ resolve(true);
|
|
|
|
|
+ }, delay);
|
|
|
|
|
+ });
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
(function($) {
|
|
(function($) {
|
|
|
$(document).ready(function() {
|
|
$(document).ready(function() {
|
|
|
|
|
+
|
|
|
|
|
+ var $mainMenu = $('#nav-menus');
|
|
|
|
|
+ var $menuBtn = $('#menu-btn');
|
|
|
|
|
+
|
|
|
QUnit.test( "hello test", function( assert ) {
|
|
QUnit.test( "hello test", function( assert ) {
|
|
|
assert.ok( 1 == "1", "Passed!" );
|
|
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);
|
|
})(jQuery);
|