From a3e0418b3357474856506000fce785db2322047f Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sun, 25 Feb 2018 09:45:51 +0100 Subject: [PATCH] working on TopNav tests --- js/privatebin.js | 4 +-- js/test/TopNav.js | 77 ++++++++++++++++++++++++++++++++++++++++++++++- tpl/bootstrap.php | 2 +- tpl/page.php | 2 +- 4 files changed, 80 insertions(+), 5 deletions(-) diff --git a/js/privatebin.js b/js/privatebin.js index 197ec58..b27e0d0 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -2568,7 +2568,7 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) { } /** - * Shows all elements belonging to viwing an existing pastes + * Shows all navigation elements for viewing an existing paste * * @name TopNav.showViewButtons * @function @@ -2589,7 +2589,7 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) { }; /** - * Hides all elements belonging to existing pastes + * Hides all navigation elements for viewing an existing paste * * @name TopNav.hideViewButtons * @function diff --git a/js/test/TopNav.js b/js/test/TopNav.js index 6b275c8..9deacf5 100644 --- a/js/test/TopNav.js +++ b/js/test/TopNav.js @@ -8,7 +8,7 @@ describe('TopNav', function () { }); it( - 'display & hide navigation elements for viewing an existing paste', + 'displays & hides navigation elements for viewing an existing paste', function () { var results = []; $('body').html( @@ -37,6 +37,81 @@ describe('TopNav', function () { $('#rawtextbutton').hasClass('hidden') && $('#qrcodelink').hasClass('hidden') ); + $.PrivateBin.TopNav.showViewButtons(); + results.push( + !$('#newbutton').hasClass('hidden') && + !$('#clonebutton').hasClass('hidden') && + !$('#rawtextbutton').hasClass('hidden') && + !$('#qrcodelink').hasClass('hidden') + ); + $.PrivateBin.TopNav.hideViewButtons(); + results.push( + $('#newbutton').hasClass('hidden') && + $('#clonebutton').hasClass('hidden') && + $('#rawtextbutton').hasClass('hidden') && + $('#qrcodelink').hasClass('hidden') + ); + cleanup(); + return results.every(element => element); + } + ); + }); + + describe('showCreateButtons & hideCreateButtons', function () { + before(function () { + cleanup(); + }); + + it( + 'displays & hides navigation elements for creating a paste', + function () { + var results = []; + $('body').html( + '' + ); + $.PrivateBin.TopNav.init(); + results.push( + $('#sendbutton').hasClass('hidden') && + $('#expiration').hasClass('hidden') && + $('#formatter').hasClass('hidden') && + $('#burnafterreadingoption').hasClass('hidden') && + $('#opendiscussionoption').hasClass('hidden') && + $('#newbutton').hasClass('hidden') && + $('#password').hasClass('hidden') && + $('#attach').hasClass('hidden') + ); + $.PrivateBin.TopNav.showCreateButtons(); + results.push( + !$('#sendbutton').hasClass('hidden') && + !$('#expiration').hasClass('hidden') && + !$('#formatter').hasClass('hidden') && + !$('#burnafterreadingoption').hasClass('hidden') && + !$('#opendiscussionoption').hasClass('hidden') && + !$('#newbutton').hasClass('hidden') && + !$('#password').hasClass('hidden') && + !$('#attach').hasClass('hidden') + ); + $.PrivateBin.TopNav.hideCreateButtons(); + results.push( + $('#sendbutton').hasClass('hidden') && + $('#expiration').hasClass('hidden') && + $('#formatter').hasClass('hidden') && + $('#burnafterreadingoption').hasClass('hidden') && + $('#opendiscussionoption').hasClass('hidden') && + $('#newbutton').hasClass('hidden') && + $('#password').hasClass('hidden') && + $('#attach').hasClass('hidden') + ); cleanup(); return results.every(element => element); } diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index c1e3a6e..cb850e6 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -75,7 +75,7 @@ if ($MARKDOWN): - + diff --git a/tpl/page.php b/tpl/page.php index 5992336..2cc35d0 100644 --- a/tpl/page.php +++ b/tpl/page.php @@ -54,7 +54,7 @@ if ($QRCODE): - +