From 5e5b394291ee39ffb91887f92afe6c4c4104e1ab Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sat, 18 May 2024 20:02:54 +0200 Subject: [PATCH] fix rawText test and split parts into hideAllButtons test --- js/test/TopNav.js | 87 ++++++++++++++++++++++++++++------------------- 1 file changed, 52 insertions(+), 35 deletions(-) diff --git a/js/test/TopNav.js b/js/test/TopNav.js index e0797d1f..008b2ba0 100644 --- a/js/test/TopNav.js +++ b/js/test/TopNav.js @@ -612,7 +612,6 @@ describe('TopNav', function () { ); }); - describe('getPassword', function () { before(function () { cleanup(); @@ -682,47 +681,65 @@ describe('TopNav', function () { ); }); + describe('hideAllButtons', function () { + before(function () { + cleanup(); + }); + + it( + 'hides all buttons correctly', + function () { + // Insert any setup code needed for the hideAllButtons function + // Example: Initialize the DOM elements required for testing + $('body').html( + '' + ); + $.PrivateBin.TopNav.init(); + $.PrivateBin.TopNav.hideAllButtons(); + + assert.ok($('#newbutton').hasClass('hidden')); + assert.ok($('#clonebutton').hasClass('hidden')); + assert.ok($('#rawtextbutton').hasClass('hidden')); + assert.ok($('#qrcodelink').hasClass('hidden')); + cleanup(); + } + ); + }); + describe('rawText', function () { before(function () { - // Insert any setup code needed for the rawText function - // Example: Initialize the DOM elements required for testing - $('body').html( - '' - ); + cleanup(); }); - + it( 'displays raw text view correctly', function () { - rawText(); - - assert.ok($('#newbutton').hasClass('hidden')); - assert.ok($('#clonebutton').hasClass('hidden')); - assert.ok(!$('#rawtextbutton').hasClass('hidden')); - assert.ok($('#qrcodelink').hasClass('hidden')); + const clean = jsdom('', {url: 'https://privatebin.net/?0123456789abcdef#0'}); + global.URL = require('jsdom-url').URL; + $('body').html(''); + const sample = 'example'; + $.PrivateBin.PasteViewer.setText(sample); + $.PrivateBin.TopNav.init(); + $('#rawtextbutton').click(); + assert.equal($('pre').text(), sample); + clean(); } ); - - after(function () { - $('body').empty(); - }); }); - - });