|
|
@@ -4,7 +4,25 @@ var common = require('../common');
|
|
|
describe('Alert', function () {
|
|
|
describe('showStatus', function () {
|
|
|
jsc.property(
|
|
|
- 'shows a status message',
|
|
|
+ 'shows a status message (basic)',
|
|
|
+ jsc.array(common.jscAlnumString()),
|
|
|
+ jsc.array(common.jscAlnumString()),
|
|
|
+ function (icon, message) {
|
|
|
+ icon = icon.join('');
|
|
|
+ message = message.join('');
|
|
|
+ const expected = '<div id="status">' + message + '</div>';
|
|
|
+ $('body').html(
|
|
|
+ '<div id="status"></div>'
|
|
|
+ );
|
|
|
+ $.PrivateBin.Alert.init();
|
|
|
+ $.PrivateBin.Alert.showStatus(message, icon);
|
|
|
+ const result = $('body').html();
|
|
|
+ return expected === result;
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
+ jsc.property(
|
|
|
+ 'shows a status message (bootstrap)',
|
|
|
jsc.array(common.jscAlnumString()),
|
|
|
jsc.array(common.jscAlnumString()),
|
|
|
function (icon, message) {
|
|
|
@@ -33,7 +51,25 @@ describe('Alert', function () {
|
|
|
});
|
|
|
|
|
|
jsc.property(
|
|
|
- 'shows an error message',
|
|
|
+ 'shows an error message (basic)',
|
|
|
+ jsc.array(common.jscAlnumString()),
|
|
|
+ jsc.array(common.jscAlnumString()),
|
|
|
+ function (icon, message) {
|
|
|
+ icon = icon.join('');
|
|
|
+ message = message.join('');
|
|
|
+ const expected = '<div id="errormessage">' + message + '</div>';
|
|
|
+ $('body').html(
|
|
|
+ '<div id="errormessage"></div>'
|
|
|
+ );
|
|
|
+ $.PrivateBin.Alert.init();
|
|
|
+ $.PrivateBin.Alert.showError(message, icon);
|
|
|
+ const result = $('body').html();
|
|
|
+ return expected === result;
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
+ jsc.property(
|
|
|
+ 'shows an error message (bootstrap)',
|
|
|
jsc.array(common.jscAlnumString()),
|
|
|
jsc.array(common.jscAlnumString()),
|
|
|
function (icon, message) {
|
|
|
@@ -56,13 +92,79 @@ describe('Alert', function () {
|
|
|
);
|
|
|
});
|
|
|
|
|
|
+ describe('showWarning', function () {
|
|
|
+ before(function () {
|
|
|
+ cleanup();
|
|
|
+ });
|
|
|
+
|
|
|
+ jsc.property(
|
|
|
+ 'shows a warning message (basic)',
|
|
|
+ jsc.array(common.jscAlnumString()),
|
|
|
+ jsc.array(common.jscAlnumString()),
|
|
|
+ function (icon, message) {
|
|
|
+ icon = icon.join('');
|
|
|
+ message = message.join('');
|
|
|
+ const expected = '<div id="errormessage">' + message + '</div>';
|
|
|
+ $('body').html(
|
|
|
+ '<div id="errormessage"></div>'
|
|
|
+ );
|
|
|
+ $.PrivateBin.Alert.init();
|
|
|
+ $.PrivateBin.Alert.showWarning(message, icon);
|
|
|
+ const result = $('body').html();
|
|
|
+ return expected === result;
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
+ jsc.property(
|
|
|
+ 'shows a warning message (bootstrap)',
|
|
|
+ jsc.array(common.jscAlnumString()),
|
|
|
+ jsc.array(common.jscAlnumString()),
|
|
|
+ function (icon, message) {
|
|
|
+ icon = icon.join('');
|
|
|
+ message = message.join('');
|
|
|
+ const expected = '<div id="errormessage" role="alert" ' +
|
|
|
+ 'class="statusmessage alert alert-danger"><span ' +
|
|
|
+ 'class="glyphicon glyphicon-' + icon +
|
|
|
+ '" aria-hidden="true"></span> ' + message + '</div>';
|
|
|
+ $('body').html(
|
|
|
+ '<div id="errormessage" role="alert" class="statusmessage ' +
|
|
|
+ 'alert alert-danger hidden"><span class="glyphicon ' +
|
|
|
+ 'glyphicon-alert" aria-hidden="true"></span> </div>'
|
|
|
+ );
|
|
|
+ $.PrivateBin.Alert.init();
|
|
|
+ $.PrivateBin.Alert.showWarning(message, icon);
|
|
|
+ const result = $('body').html();
|
|
|
+ return expected === result;
|
|
|
+ }
|
|
|
+ );
|
|
|
+ });
|
|
|
+
|
|
|
describe('showRemaining', function () {
|
|
|
before(function () {
|
|
|
cleanup();
|
|
|
});
|
|
|
|
|
|
jsc.property(
|
|
|
- 'shows remaining time',
|
|
|
+ 'shows remaining time (basic)',
|
|
|
+ jsc.array(common.jscAlnumString()),
|
|
|
+ jsc.array(common.jscAlnumString()),
|
|
|
+ 'integer',
|
|
|
+ function (message, string, number) {
|
|
|
+ message = message.join('');
|
|
|
+ string = string.join('');
|
|
|
+ const expected = '<div id="remainingtime" class="">' + string + message + number + '</div>';
|
|
|
+ $('body').html(
|
|
|
+ '<div id="remainingtime" class="hidden"></div>'
|
|
|
+ );
|
|
|
+ $.PrivateBin.Alert.init();
|
|
|
+ $.PrivateBin.Alert.showRemaining(['%s' + message + '%d', string, number]);
|
|
|
+ const result = $('body').html();
|
|
|
+ return expected === result;
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
+ jsc.property(
|
|
|
+ 'shows remaining time (bootstrap)',
|
|
|
jsc.array(common.jscAlnumString()),
|
|
|
jsc.array(common.jscAlnumString()),
|
|
|
'integer',
|
|
|
@@ -92,7 +194,29 @@ describe('Alert', function () {
|
|
|
});
|
|
|
|
|
|
jsc.property(
|
|
|
- 'shows a loading message',
|
|
|
+ 'shows a loading message (basic)',
|
|
|
+ jsc.array(common.jscAlnumString()),
|
|
|
+ jsc.array(common.jscAlnumString()),
|
|
|
+ function (message, icon) {
|
|
|
+ message = message.join('');
|
|
|
+ icon = icon.join('');
|
|
|
+ const defaultMessage = 'Loading…';
|
|
|
+ if (message.length === 0) {
|
|
|
+ message = defaultMessage;
|
|
|
+ }
|
|
|
+ const expected = '<div id="loadingindicator" class="">' + message + '</div>';
|
|
|
+ $('body').html(
|
|
|
+ '<div id="loadingindicator" class="hidden">' + defaultMessage + '</div>'
|
|
|
+ );
|
|
|
+ $.PrivateBin.Alert.init();
|
|
|
+ $.PrivateBin.Alert.showLoading(message, icon);
|
|
|
+ const result = $('body').html();
|
|
|
+ return expected === result;
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
+ jsc.property(
|
|
|
+ 'shows a loading message (bootstrap)',
|
|
|
jsc.array(common.jscAlnumString()),
|
|
|
jsc.array(common.jscAlnumString()),
|
|
|
function (message, icon) {
|
|
|
@@ -102,7 +226,7 @@ describe('Alert', function () {
|
|
|
if (message.length === 0) {
|
|
|
message = defaultMessage;
|
|
|
}
|
|
|
- var expected = '<ul class="nav navbar-nav"><li ' +
|
|
|
+ const expected = '<ul class="nav navbar-nav"><li ' +
|
|
|
'id="loadingindicator" class="navbar-text"><span ' +
|
|
|
'class="glyphicon glyphicon-' + icon +
|
|
|
'" aria-hidden="true"></span> ' + message + '</li></ul>';
|