mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2024-10-01 01:26:10 -04:00
introduce built in asserts, working on TopNav, correcting some docs
This commit is contained in:
parent
cb2af8687e
commit
ce6764e97d
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -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')
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
@ -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')
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
@ -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')
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
@ -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(
|
||||
'<nav><div id="navbar"><ul><li><button id="newbutton" type=' +
|
||||
'"button" class="hidden">New</button></li></ul></div></nav>'
|
||||
);
|
||||
$.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(
|
||||
'<nav><div id="navbar"><ul><li><button id="clonebutton" ' +
|
||||
'type="button" class="btn btn-warning navbar-btn">' +
|
||||
'<span class="glyphicon glyphicon-duplicate" aria-hidden=' +
|
||||
'"true"></span> Clone</button></li></ul></div></nav>'
|
||||
);
|
||||
$.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(
|
||||
'<nav><div id="navbar"><ul><li><button ' +
|
||||
'id="rawtextbutton" type="button" class="btn ' +
|
||||
'btn-warning navbar-btn"><span class="glyphicon ' +
|
||||
'glyphicon-text-background" aria-hidden="true"></span> ' +
|
||||
'Raw text</button></li></ul></div></nav>'
|
||||
);
|
||||
$.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(
|
||||
'<nav><div id="navbar"><ul><li id="attach" class="hidden ' +
|
||||
'dropdown"><a href="#" class="dropdown-toggle" data-' +
|
||||
'toggle="dropdown" role="button" aria-haspopup="true" ' +
|
||||
'aria-expanded="false">Attach a file <span class="caret">' +
|
||||
'</span></a><ul class="dropdown-menu"><li id="filewrap">' +
|
||||
'<div><input type="file" id="file" name="file" /></div>' +
|
||||
'</li><li id="customattachment" class="hidden"></li><li>' +
|
||||
'<a id="fileremovebutton" href="#">Remove attachment</a>' +
|
||||
'</li></ul></li></ul></div></nav>'
|
||||
);
|
||||
$.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(
|
||||
'<nav><div id="navbar"><ul><li id="attach" class="hidden ' +
|
||||
'dropdown"><a href="#" class="dropdown-toggle" data-' +
|
||||
'toggle="dropdown" role="button" aria-haspopup="true" ' +
|
||||
'aria-expanded="false">Attach a file <span class="caret">' +
|
||||
'</span></a><ul class="dropdown-menu"><li id="filewrap">' +
|
||||
'<div><input type="file" id="file" name="file" /></div>' +
|
||||
'</li><li id="customattachment" class="hidden"></li><li>' +
|
||||
'<a id="fileremovebutton" href="#">Remove attachment</a>' +
|
||||
'</li></ul></li></ul></div></nav>'
|
||||
);
|
||||
$.PrivateBin.TopNav.init();
|
||||
results.push(
|
||||
$('#customattachment').hasClass('hidden')
|
||||
);
|
||||
$.PrivateBin.TopNav.showCustomAttachment();
|
||||
results.push(
|
||||
!$('#customattachment').hasClass('hidden')
|
||||
);
|
||||
cleanup();
|
||||
assert.ok(results.every(element => element));
|
||||
}
|
||||
);
|
||||
});
|
||||
|
@ -75,7 +75,7 @@ if ($MARKDOWN):
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-1taLHBI+tdu4RhEpnqw4JfGHePYdAmO9zwrIFh5Ym1R4XJWt4ls/3br9u/6kS5dN8s5RqZSRUz/nmsaauwUzAA==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-Z3SG68lkzr8/Hg8goFersCg5T8qrI2dUKDCRnlA6uZanWLiKRCBBX8gNHgjSdPp/+XC3fFFTGL3KCZFgCXXdtQ==" crossorigin="anonymous"></script>
|
||||
<!--[if lt IE 10]>
|
||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||
<![endif]-->
|
||||
|
@ -54,7 +54,7 @@ if ($QRCODE):
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-1taLHBI+tdu4RhEpnqw4JfGHePYdAmO9zwrIFh5Ym1R4XJWt4ls/3br9u/6kS5dN8s5RqZSRUz/nmsaauwUzAA==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-Z3SG68lkzr8/Hg8goFersCg5T8qrI2dUKDCRnlA6uZanWLiKRCBBX8gNHgjSdPp/+XC3fFFTGL3KCZFgCXXdtQ==" crossorigin="anonymous"></script>
|
||||
<!--[if lt IE 10]>
|
||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||
<![endif]-->
|
||||
|
Loading…
Reference in New Issue
Block a user