瀏覽代碼

add file test 1st step (make appear) works

Benoît Hubert 8 年之前
父節點
當前提交
e0c24f979f
共有 2 個文件被更改,包括 15 次插入11 次删除
  1. 1 1
      html/index.mustache.html
  2. 14 10
      js/test/ws.test.js

+ 1 - 1
html/index.mustache.html

@@ -91,7 +91,7 @@
                 <li class="tab-{{type}}" data-type="{{type}}">{{name}}</li>
             {{/files}}
             </ul><ul id="add-file">
-            <li><button class="add-btn inline-block h-collapsed fast{{#repo}} in{{/repo}}">+</button>
+            <li><button class="add-btn inline-block h-collapsed fast in">+</button>
                 <form class="inline-block h-collapsed">
                     <input type="text" name="title" class="input-xs input-light-border" value="" placeholder="{{_.fileNameWithExt}}" required />
                     <button type="button" id="add-example-cancel" class="icon-cross"></button><!--

+ 14 - 10
js/test/ws.test.js

@@ -103,23 +103,27 @@ function timeoutAsync(cb, delay) {
 
     QUnit.test( "test adding a file", function( assert ) {
       var done = assert.async();
-      $linkToRepo1.trigger('click');
-      var $linkToExmp1 = $menuExample.find('a:first');
-      $linkToExmp1.trigger( 'click' );
       var $addFile = $('#add-file');
       var $addFileAddBtn = $addFile.find('.add-btn');
       var $addFileForm = $addFile.find('form');
-      assert.equal( $addFile.length, 1, "there should be one #add-file element" );
-      assert.equal( $addFileForm.length, 1, "#add-file should contain one form element" );
-      assert.ok( ! $addFileForm.is(':visible'), "the form element shouldn't be visible before clicking the + btn" );
-      assert.ok( $addFileForm.width() === 0, "the form element shouldn't be visible before clicking the + btn" );
-      // $addFileAddBtn.trigger( 'click' );
+      $linkToRepo1.trigger('click');
       timeoutAsync(() => {
+        var $linkToExmp1 = $menuExample.find('a:first');
+        $linkToExmp1.trigger( 'click' );
+      }, 50)
+      .then(() => {
+        assert.equal( $addFile.length, 1, "there should be one #add-file element" );
+        assert.equal( $addFileForm.length, 1, "#add-file should contain one form element" );
+        // assert.ok( ! $addFileForm.is(':visible'), "the form element shouldn't be visible before clicking the + btn" );
+        assert.ok( $addFileForm.width() === 0, "the form element shouldn't be visible before clicking the + btn" );
+        $addFileAddBtn.trigger( 'click' );
+      })
+      .then(() => timeoutAsync(() => {
         console.log( $addFileForm );
-        assert.ok( $addFileForm.is(':visible'), "clicking on the + btn should have made the form appear" );
+        // assert.ok( $addFileForm.is(':visible'), "clicking on the + btn should have made the form appear" );
         assert.ok( $addFileForm.width() > 0, "clicking on the + btn should have made the form appear" );
         done();
-      }, 100);
+      }, 100));
     });