Bladeren bron

try and test #add-file

Benoît Hubert 8 jaren geleden
bovenliggende
commit
1997a1a736
2 gewijzigde bestanden met toevoegingen van 26 en 2 verwijderingen
  1. 25 1
      js/test/ws.test.js
  2. 1 1
      js/ws-ui-parts.js

+ 25 - 1
js/test/ws.test.js

@@ -60,7 +60,7 @@ function timeoutAsync(cb, delay) {
       var done = assert.async();
       assert.equal( window.location.pathname, '/', "location should be / at first" );
       $linkToRepo1.trigger('click');
-      assert.equal( window.location.pathname, '/example-repo1' );
+      assert.equal( window.location.pathname, '/example-repo1', "location should be /example-repo1" );
       timeoutAsync(() => {
         assert.equal( ($menuExample.find('a')).length, 1, "menu example should contain 1 entry" );
         assert.equal( $menuExample.find('a:first').html(), "Test Example", "link to 1st example should be labelled 'Test Example'" );
@@ -73,6 +73,8 @@ function timeoutAsync(cb, delay) {
 
     QUnit.test( "test nav to example", function( assert ) {
       var done = assert.async();
+      $linkToRepo1.trigger('click');
+      assert.equal( window.location.pathname, '/example-repo1', "location should be /example-repo1" );
       assert.equal( ($menuExample.find('a')).length, 1, "menu example should contain 1 entry" );
       var $linkToExmp1 = $menuExample.find('a:first');
       $linkToExmp1.trigger('click');
@@ -99,6 +101,28 @@ function timeoutAsync(cb, delay) {
       done();
     });
 
+    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' );
+      timeoutAsync(() => {
+        console.log( $addFileForm );
+        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);
+    });
+
+
     QUnit.test( "test nav back to home", function( assert ) {
       var done = assert.async();
       $homeLink.trigger('click');

+ 1 - 1
js/ws-ui-parts.js

@@ -47,7 +47,7 @@
         var evtName = bits.shift();
         var selector = bits.join(' ');
         var target = selector === '' ? this.$elem : this.$elem.find(selector);
-        console.log('#### bind', descriptor, 'e:' + evtName, 's:[' + selector + '], target:', target);
+        // console.log('#### bind', descriptor, 'e:' + evtName, 's:[' + selector + '], target:', target);
         target.on(evtName, handler.bind(this));
       }
     }