fix rawText test and split parts into hideAllButtons test

This commit is contained in:
El RIDO 2024-05-18 20:02:54 +02:00
parent 39a359c23f
commit 5e5b394291

View file

@ -612,7 +612,6 @@ describe('TopNav', function () {
);
});
describe('getPassword', function () {
before(function () {
cleanup();
@ -682,9 +681,15 @@ describe('TopNav', function () {
);
});
describe('rawText', function () {
describe('hideAllButtons', function () {
before(function () {
// Insert any setup code needed for the rawText 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(
'<nav class="navbar navbar-inverse navbar-static-top">' +
@ -705,24 +710,36 @@ describe('TopNav', function () {
'class="glyphicon glyphicon-qrcode" aria-hidden="true">' +
'</span> QR code</button></li></ul></div></nav>'
);
$.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 () {
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('<button id="rawtextbutton"></button>');
const sample = 'example';
$.PrivateBin.PasteViewer.setText(sample);
$.PrivateBin.TopNav.init();
$('#rawtextbutton').click();
assert.equal($('pre').text(), sample);
clean();
}
);
after(function () {
$('body').empty();
});
});
});