|
|
@@ -3,21 +3,56 @@ var common = require('../common');
|
|
|
|
|
|
describe('Alert', function () {
|
|
|
describe('showStatus', function () {
|
|
|
- before(function () {
|
|
|
- cleanup();
|
|
|
- });
|
|
|
-
|
|
|
jsc.property(
|
|
|
'shows a status message',
|
|
|
jsc.array(common.jscAlnumString()),
|
|
|
jsc.array(common.jscAlnumString()),
|
|
|
+ function (icon, message) {
|
|
|
+ icon = icon.join('');
|
|
|
+ message = message.join('');
|
|
|
+ var expected = '<div id="status">' + message + '</div>';
|
|
|
+ $('body').html(
|
|
|
+ '<div id="status"></div>'
|
|
|
+ );
|
|
|
+ $.PrivateBin.Alert.init();
|
|
|
+ $.PrivateBin.Alert.showStatus(message, icon);
|
|
|
+ var result = $('body').html();
|
|
|
+ return expected === result;
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
+ jsc.property(
|
|
|
+ 'shows a status message (bootstrap)',
|
|
|
+ jsc.array(common.jscAlnumString()),
|
|
|
+ function (message) {
|
|
|
+ message = message.join('');
|
|
|
+ var expected = '<div id="status" role="alert" ' +
|
|
|
+ 'class="statusmessage alert alert-info"><span ' +
|
|
|
+ 'class="glyphicon glyphicon-info-sign" ' +
|
|
|
+ 'aria-hidden="true"></span> <span>' + message + '</span></div>';
|
|
|
+ $('body').html(
|
|
|
+ '<div id="status" role="alert" class="statusmessage ' +
|
|
|
+ 'alert alert-info hidden"><span class="glyphicon ' +
|
|
|
+ 'glyphicon-info-sign" aria-hidden="true"></span> </div>'
|
|
|
+ );
|
|
|
+ $.PrivateBin.Alert.init();
|
|
|
+ $.PrivateBin.Alert.showStatus(message);
|
|
|
+ var result = $('body').html();
|
|
|
+ return expected === result;
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
+ jsc.property(
|
|
|
+ 'shows a status message (bootstrap, custom icon)',
|
|
|
+ jsc.array(common.jscAlnumString()),
|
|
|
+ jsc.array(common.jscAlnumString()),
|
|
|
function (icon, message) {
|
|
|
icon = icon.join('');
|
|
|
message = message.join('');
|
|
|
var expected = '<div id="status" role="alert" ' +
|
|
|
'class="statusmessage alert alert-info"><span ' +
|
|
|
'class="glyphicon glyphicon-' + icon +
|
|
|
- '" aria-hidden="true"></span> ' + message + '</div>';
|
|
|
+ '" aria-hidden="true"></span> <span>' + message + '</span></div>';
|
|
|
$('body').html(
|
|
|
'<div id="status" role="alert" class="statusmessage ' +
|
|
|
'alert alert-info hidden"><span class="glyphicon ' +
|
|
|
@@ -32,12 +67,48 @@ describe('Alert', function () {
|
|
|
});
|
|
|
|
|
|
describe('showError', function () {
|
|
|
- before(function () {
|
|
|
- cleanup();
|
|
|
- });
|
|
|
+ jsc.property(
|
|
|
+ 'shows an error message (basic)',
|
|
|
+ jsc.array(common.jscAlnumString()),
|
|
|
+ jsc.array(common.jscAlnumString()),
|
|
|
+ function (icon, message) {
|
|
|
+ icon = icon.join('');
|
|
|
+ message = message.join('');
|
|
|
+ var expected = '<div id="errormessage">' + message + '</div>';
|
|
|
+ $('body').html(
|
|
|
+ '<div id="errormessage"></div>'
|
|
|
+ );
|
|
|
+ $.PrivateBin.Alert.init();
|
|
|
+ $.PrivateBin.Alert.showError(message, icon);
|
|
|
+ var result = $('body').html();
|
|
|
+ return expected === result;
|
|
|
+ }
|
|
|
+ );
|
|
|
|
|
|
jsc.property(
|
|
|
- 'shows an error message',
|
|
|
+ 'shows an error message (bootstrap)',
|
|
|
+ jsc.array(common.jscAlnumString()),
|
|
|
+ jsc.array(common.jscAlnumString()),
|
|
|
+ function (icon, message) {
|
|
|
+ message = message.join('');
|
|
|
+ var expected = '<div id="errormessage" role="alert" ' +
|
|
|
+ 'class="statusmessage alert alert-danger"><span ' +
|
|
|
+ 'class="glyphicon glyphicon-alert" ' +
|
|
|
+ 'aria-hidden="true"></span> <span>' + message + '</span></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.showError(message);
|
|
|
+ var result = $('body').html();
|
|
|
+ return expected === result;
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
+ jsc.property(
|
|
|
+ 'shows an error message (bootstrap, custom icon)',
|
|
|
jsc.array(common.jscAlnumString()),
|
|
|
jsc.array(common.jscAlnumString()),
|
|
|
function (icon, message) {
|
|
|
@@ -46,7 +117,7 @@ describe('Alert', function () {
|
|
|
var expected = '<div id="errormessage" role="alert" ' +
|
|
|
'class="statusmessage alert alert-danger"><span ' +
|
|
|
'class="glyphicon glyphicon-' + icon +
|
|
|
- '" aria-hidden="true"></span> ' + message + '</div>';
|
|
|
+ '" aria-hidden="true"></span> <span>' + message + '</span></div>';
|
|
|
$('body').html(
|
|
|
'<div id="errormessage" role="alert" class="statusmessage ' +
|
|
|
'alert alert-danger hidden"><span class="glyphicon ' +
|
|
|
@@ -61,12 +132,27 @@ describe('Alert', function () {
|
|
|
});
|
|
|
|
|
|
describe('showRemaining', function () {
|
|
|
- before(function () {
|
|
|
- cleanup();
|
|
|
- });
|
|
|
+ jsc.property(
|
|
|
+ 'shows remaining time (basic)',
|
|
|
+ jsc.array(common.jscAlnumString()),
|
|
|
+ jsc.array(common.jscAlnumString()),
|
|
|
+ 'integer',
|
|
|
+ function (message, string, number) {
|
|
|
+ message = message.join('');
|
|
|
+ string = string.join('');
|
|
|
+ var 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]);
|
|
|
+ var result = $('body').html();
|
|
|
+ return expected === result;
|
|
|
+ }
|
|
|
+ );
|
|
|
|
|
|
jsc.property(
|
|
|
- 'shows remaining time',
|
|
|
+ 'shows remaining time (bootstrap)',
|
|
|
jsc.array(common.jscAlnumString()),
|
|
|
jsc.array(common.jscAlnumString()),
|
|
|
'integer',
|
|
|
@@ -76,7 +162,7 @@ describe('Alert', function () {
|
|
|
var expected = '<div id="remainingtime" role="alert" ' +
|
|
|
'class="alert alert-info"><span ' +
|
|
|
'class="glyphicon glyphicon-fire" aria-hidden="true">' +
|
|
|
- '</span> ' + string + message + number + '</div>';
|
|
|
+ '</span> <span>' + string + message + number + '</span></div>';
|
|
|
$('body').html(
|
|
|
'<div id="remainingtime" role="alert" class="hidden ' +
|
|
|
'alert alert-info"><span class="glyphicon ' +
|
|
|
@@ -91,12 +177,30 @@ describe('Alert', function () {
|
|
|
});
|
|
|
|
|
|
describe('showLoading', function () {
|
|
|
- before(function () {
|
|
|
- cleanup();
|
|
|
- });
|
|
|
+ jsc.property(
|
|
|
+ 'shows a loading message (basic)',
|
|
|
+ jsc.array(common.jscAlnumString()),
|
|
|
+ jsc.array(common.jscAlnumString()),
|
|
|
+ function (message, icon) {
|
|
|
+ message = message.join('');
|
|
|
+ icon = icon.join('');
|
|
|
+ var defaultMessage = 'Loading…';
|
|
|
+ if (message.length === 0) {
|
|
|
+ message = defaultMessage;
|
|
|
+ }
|
|
|
+ var expected = '<div id="loadingindicator" class="">' + message + '</div>';
|
|
|
+ $('body').html(
|
|
|
+ '<div id="loadingindicator" class="hidden">' + defaultMessage + '</div>'
|
|
|
+ );
|
|
|
+ $.PrivateBin.Alert.init();
|
|
|
+ $.PrivateBin.Alert.showLoading(message, icon);
|
|
|
+ var result = $('body').html();
|
|
|
+ return expected === result;
|
|
|
+ }
|
|
|
+ );
|
|
|
|
|
|
jsc.property(
|
|
|
- 'shows a loading message',
|
|
|
+ 'shows a loading message (bootstrap)',
|
|
|
jsc.array(common.jscAlnumString()),
|
|
|
jsc.array(common.jscAlnumString()),
|
|
|
function (message, icon) {
|
|
|
@@ -109,7 +213,7 @@ describe('Alert', function () {
|
|
|
var expected = '<ul class="nav navbar-nav"><li ' +
|
|
|
'id="loadingindicator" class="navbar-text"><span ' +
|
|
|
'class="glyphicon glyphicon-' + icon +
|
|
|
- '" aria-hidden="true"></span> ' + message + '</li></ul>';
|
|
|
+ '" aria-hidden="true"></span> <span>' + message + '</span></li></ul>';
|
|
|
$('body').html(
|
|
|
'<ul class="nav navbar-nav"><li id="loadingindicator" ' +
|
|
|
'class="navbar-text hidden"><span class="glyphicon ' +
|
|
|
@@ -125,10 +229,6 @@ describe('Alert', function () {
|
|
|
});
|
|
|
|
|
|
describe('hideLoading', function () {
|
|
|
- before(function () {
|
|
|
- cleanup();
|
|
|
- });
|
|
|
-
|
|
|
it(
|
|
|
'hides the loading message',
|
|
|
function() {
|
|
|
@@ -150,10 +250,6 @@ describe('Alert', function () {
|
|
|
});
|
|
|
|
|
|
describe('hideMessages', function () {
|
|
|
- before(function () {
|
|
|
- cleanup();
|
|
|
- });
|
|
|
-
|
|
|
it(
|
|
|
'hides all messages',
|
|
|
function() {
|
|
|
@@ -176,10 +272,6 @@ describe('Alert', function () {
|
|
|
});
|
|
|
|
|
|
describe('setCustomHandler', function () {
|
|
|
- before(function () {
|
|
|
- cleanup();
|
|
|
- });
|
|
|
-
|
|
|
jsc.property(
|
|
|
'calls a given handler function',
|
|
|
'nat 3',
|