diff --git a/js/common.js b/js/common.js index c60a7064..3ab49992 100644 --- a/js/common.js +++ b/js/common.js @@ -1,6 +1,7 @@ 'use strict'; // testing prerequisites +global.assert = require('assert'); global.jsc = require('jsverify'); global.jsdom = require('jsdom-global'); global.cleanup = global.jsdom(); diff --git a/js/privatebin.js b/js/privatebin.js index 240726f5..395ac0ee 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -1290,7 +1290,7 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) { /** * hides the remaining time and successful upload notification * - * @name PasteStatus.hideRemainingTime + * @name PasteStatus.hideMessages * @function */ me.hideMessages = function() @@ -2884,6 +2884,9 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) { // get default value from template or fall back to set value pasteExpiration = Model.getExpirationDefault() || pasteExpiration; + + createButtonsDisplayed = false; + viewButtonsDisplayed = false; }; return me; diff --git a/js/test/Alert.js b/js/test/Alert.js index 2f0a2df8..617c4889 100644 --- a/js/test/Alert.js +++ b/js/test/Alert.js @@ -141,8 +141,10 @@ describe('Alert', function () { $('body').addClass('loading'); $.PrivateBin.Alert.init(); $.PrivateBin.Alert.hideLoading(); - return !$('body').hasClass('loading') && - $('#loadingindicator').hasClass('hidden'); + assert.ok( + !$('body').hasClass('loading') && + $('#loadingindicator').hasClass('hidden') + ); } ); }); @@ -165,8 +167,10 @@ describe('Alert', function () { ); $.PrivateBin.Alert.init(); $.PrivateBin.Alert.hideMessages(); - return $('#statusmessage').hasClass('hidden') && - $('#errormessage').hasClass('hidden'); + assert.ok( + $('#status').hasClass('hidden') && + $('#errormessage').hasClass('hidden') + ); } ); }); diff --git a/js/test/CryptTool.js b/js/test/CryptTool.js index 398ff75b..3c89fff3 100644 --- a/js/test/CryptTool.js +++ b/js/test/CryptTool.js @@ -87,9 +87,10 @@ describe('CryptTool', function () { 'MZtmnYpGAtAPg7AUG"}' ); - if (!paste1.includes('securely packed in iron') || !paste2.includes('Sol is right')) { - throw Error('v1 (SJCL based) pastes could not be deciphered'); - } + assert.ok( + paste1.includes('securely packed in iron') && + paste2.includes('Sol is right') + ); } ); @@ -152,9 +153,10 @@ describe('CryptTool', function () { jsdom(); delete require.cache[require.resolve('../privatebin')]; require('../privatebin'); - if (!paste1.includes('securely packed in iron') || !paste2.includes('Sol is right')) { - throw Error('v1 (SJCL based) pastes could not be deciphered'); - } + assert.ok( + paste1.includes('securely packed in iron') && + paste2.includes('Sol is right') + ); } ); }); diff --git a/js/test/PasteStatus.js b/js/test/PasteStatus.js index 1c31813d..6b0805d3 100644 --- a/js/test/PasteStatus.js +++ b/js/test/PasteStatus.js @@ -96,8 +96,10 @@ describe('PasteStatus', function () { ); $.PrivateBin.PasteStatus.init(); $.PrivateBin.PasteStatus.hideMessages(); - return $('#remainingtime').hasClass('hidden') && - $('#pastesuccess').hasClass('hidden'); + assert.ok( + $('#remainingtime').hasClass('hidden') && + $('#pastesuccess').hasClass('hidden') + ); } ); }); diff --git a/js/test/TopNav.js b/js/test/TopNav.js index 9deacf57..ba7ffad3 100644 --- a/js/test/TopNav.js +++ b/js/test/TopNav.js @@ -52,7 +52,7 @@ describe('TopNav', function () { $('#qrcodelink').hasClass('hidden') ); cleanup(); - return results.every(element => element); + assert.ok(results.every(element => element)); } ); }); @@ -113,7 +113,161 @@ describe('TopNav', function () { $('#attach').hasClass('hidden') ); cleanup(); - return results.every(element => element); + assert.ok(results.every(element => element)); + } + ); + }); + + describe('showNewPasteButton', function () { + before(function () { + cleanup(); + }); + + it( + 'displays the button for creating a paste', + function () { + var results = []; + $('body').html( + '' + ); + $.PrivateBin.TopNav.init(); + results.push( + $('#newbutton').hasClass('hidden') + ); + $.PrivateBin.TopNav.showNewPasteButton(); + results.push( + !$('#newbutton').hasClass('hidden') + ); + cleanup(); + assert.ok(results.every(element => element)); + } + ); + }); + + describe('hideCloneButton', function () { + before(function () { + cleanup(); + }); + + it( + 'hides the button for cloning a paste', + function () { + var results = []; + $('body').html( + '' + ); + $.PrivateBin.TopNav.init(); + results.push( + !$('#clonebutton').hasClass('hidden') + ); + $.PrivateBin.TopNav.hideCloneButton(); + results.push( + $('#clonebutton').hasClass('hidden') + ); + cleanup(); + assert.ok(results.every(element => element)); + } + ); + }); + + describe('hideRawButton', function () { + before(function () { + cleanup(); + }); + + it( + 'hides the raw text button', + function () { + var results = []; + $('body').html( + '' + ); + $.PrivateBin.TopNav.init(); + results.push( + !$('#rawtextbutton').hasClass('hidden') + ); + $.PrivateBin.TopNav.hideRawButton(); + results.push( + $('#rawtextbutton').hasClass('hidden') + ); + cleanup(); + assert.ok(results.every(element => element)); + } + ); + }); + + describe('hideFileSelector', function () { + before(function () { + cleanup(); + }); + + it( + 'hides the file attachment selection button', + function () { + var results = []; + $('body').html( + '' + ); + $.PrivateBin.TopNav.init(); + results.push( + !$('#filewrap').hasClass('hidden') + ); + $.PrivateBin.TopNav.hideFileSelector(); + results.push( + $('#filewrap').hasClass('hidden') + ); + cleanup(); + assert.ok(results.every(element => element)); + } + ); + }); + + describe('showCustomAttachment', function () { + before(function () { + cleanup(); + }); + + it( + 'display the custom file attachment', + function () { + var results = []; + $('body').html( + '' + ); + $.PrivateBin.TopNav.init(); + results.push( + $('#customattachment').hasClass('hidden') + ); + $.PrivateBin.TopNav.showCustomAttachment(); + results.push( + !$('#customattachment').hasClass('hidden') + ); + cleanup(); + assert.ok(results.every(element => element)); } ); }); diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index c39d516a..ee078fa4 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 a65b3615..ac94a65b 100644 --- a/tpl/page.php +++ b/tpl/page.php @@ -54,7 +54,7 @@ if ($QRCODE): - +