| 123456789101112131415161718192021222324252627282930313233343536373839 |
- 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);
|