completing DiscussionViewer testing
This commit is contained in:
parent
fcb4249e01
commit
a95701bba8
@ -977,7 +977,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||||||
if (typeof customHandler === 'function') {
|
if (typeof customHandler === 'function') {
|
||||||
var handlerResult = customHandler(alertType[id], $element, args, icon);
|
var handlerResult = customHandler(alertType[id], $element, args, icon);
|
||||||
if (handlerResult === true) {
|
if (handlerResult === true) {
|
||||||
// if it returs true, skip own handler
|
// if it returns true, skip own handler
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (handlerResult instanceof jQuery) {
|
if (handlerResult instanceof jQuery) {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
var common = require('../common');
|
var common = require('../common');
|
||||||
|
|
||||||
describe('DiscussionViewer', function () {
|
describe('DiscussionViewer', function () {
|
||||||
describe('handleNotification, addComment, finishDiscussion, prepareNewDiscussion, getReplyMessage, getReplyNickname, getReplyCommentId & highlightComment', function () {
|
describe('handleNotification, prepareNewDiscussion, addComment, finishDiscussion, getReplyMessage, getReplyNickname, getReplyCommentId & highlightComment', function () {
|
||||||
this.timeout(30000);
|
this.timeout(30000);
|
||||||
before(function () {
|
before(function () {
|
||||||
cleanup();
|
cleanup();
|
||||||
@ -12,8 +12,8 @@ describe('DiscussionViewer', function () {
|
|||||||
'displays & hides comments as requested',
|
'displays & hides comments as requested',
|
||||||
jsc.array(
|
jsc.array(
|
||||||
jsc.record({
|
jsc.record({
|
||||||
id: jsc.nearray(common.jscAlnumString()),
|
idArray: jsc.nearray(common.jscAlnumString()),
|
||||||
parentid: jsc.nearray(common.jscAlnumString()),
|
parentidArray: jsc.nearray(common.jscAlnumString()),
|
||||||
data: jsc.string,
|
data: jsc.string,
|
||||||
meta: jsc.record({
|
meta: jsc.record({
|
||||||
nickname: jsc.string,
|
nickname: jsc.string,
|
||||||
@ -22,7 +22,13 @@ describe('DiscussionViewer', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
function (comments) {
|
'nat',
|
||||||
|
'bool',
|
||||||
|
'string',
|
||||||
|
'string',
|
||||||
|
jsc.elements(['loading', 'danger', 'other']),
|
||||||
|
'nestring',
|
||||||
|
function (comments, commentKey, fadeOut, nickname, message, alertType, alert) {
|
||||||
var clean = jsdom(),
|
var clean = jsdom(),
|
||||||
results = [];
|
results = [];
|
||||||
$('body').html(
|
$('body').html(
|
||||||
@ -45,6 +51,7 @@ describe('DiscussionViewer', function () {
|
|||||||
'aria-hidden="true"></span> </div><button id="replybutton" ' +
|
'aria-hidden="true"></span> </div><button id="replybutton" ' +
|
||||||
'class="btn btn-default btn-sm">Post comment</button></div></div>'
|
'class="btn btn-default btn-sm">Post comment</button></div></div>'
|
||||||
);
|
);
|
||||||
|
$.PrivateBin.Model.init();
|
||||||
$.PrivateBin.DiscussionViewer.init();
|
$.PrivateBin.DiscussionViewer.init();
|
||||||
results.push(
|
results.push(
|
||||||
!$('#discussion').hasClass('hidden')
|
!$('#discussion').hasClass('hidden')
|
||||||
@ -53,18 +60,53 @@ describe('DiscussionViewer', function () {
|
|||||||
results.push(
|
results.push(
|
||||||
$('#discussion').hasClass('hidden')
|
$('#discussion').hasClass('hidden')
|
||||||
);
|
);
|
||||||
comments.forEach(function (originalComment) {
|
comments.forEach(function (comment) {
|
||||||
var comment = {
|
comment.id = comment.idArray.join('');
|
||||||
id: originalComment.id.join(''),
|
comment.parentid = comment.parentidArray.join('');
|
||||||
parentid: originalComment.parentid.join(''),
|
|
||||||
data: originalComment.data,
|
|
||||||
meta: originalComment.meta
|
|
||||||
}
|
|
||||||
$.PrivateBin.DiscussionViewer.addComment(comment, comment.data, comment.meta.nickname);
|
$.PrivateBin.DiscussionViewer.addComment(comment, comment.data, comment.meta.nickname);
|
||||||
});
|
});
|
||||||
results.push(
|
results.push(
|
||||||
$('#discussion').hasClass('hidden')
|
$('#discussion').hasClass('hidden')
|
||||||
);
|
);
|
||||||
|
$.PrivateBin.DiscussionViewer.finishDiscussion();
|
||||||
|
results.push(
|
||||||
|
!$('#discussion').hasClass('hidden') &&
|
||||||
|
comments.length + 1 >= $('#commentcontainer').children().length
|
||||||
|
);
|
||||||
|
if (comments.length > 0) {
|
||||||
|
if (commentKey >= comments.length) {
|
||||||
|
commentKey = commentKey % comments.length;
|
||||||
|
}
|
||||||
|
$.PrivateBin.DiscussionViewer.highlightComment(comments[commentKey].id, fadeOut);
|
||||||
|
results.push(
|
||||||
|
$('#comment_' + comments[commentKey].id).hasClass('highlight')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$('#commentcontainer').find('button')[0].click();
|
||||||
|
results.push(
|
||||||
|
!$('#reply').hasClass('hidden')
|
||||||
|
);
|
||||||
|
$('#reply #nickname').val(nickname);
|
||||||
|
$('#reply #replymessage').val(message);
|
||||||
|
$.PrivateBin.DiscussionViewer.getReplyCommentId();
|
||||||
|
results.push(
|
||||||
|
$.PrivateBin.DiscussionViewer.getReplyNickname() === $('#reply #nickname').val() &&
|
||||||
|
$.PrivateBin.DiscussionViewer.getReplyMessage() === $('#reply #replymessage').val()
|
||||||
|
);
|
||||||
|
var notificationResult = $.PrivateBin.DiscussionViewer.handleNotification(alertType == 'other' ? alert : alertType);
|
||||||
|
if (alertType == 'loading') {
|
||||||
|
results.push(notificationResult === false);
|
||||||
|
} else {
|
||||||
|
results.push(
|
||||||
|
alertType == 'danger' ? (
|
||||||
|
notificationResult.hasClass('alert-danger') &&
|
||||||
|
!notificationResult.hasClass('alert-info')
|
||||||
|
) : (
|
||||||
|
!notificationResult.hasClass('alert-danger') &&
|
||||||
|
notificationResult.hasClass('alert-info')
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
clean();
|
clean();
|
||||||
return results.every(element => element);
|
return results.every(element => element);
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ if ($MARKDOWN):
|
|||||||
<?php
|
<?php
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-msvuz4bHPzxA4SPt80AzVlD8DybEUb+3819GfmoyMin//9poPKN7cPp8pXgLwQUxxaxYK9bUpXj7UmbSNLU+Xg==" crossorigin="anonymous"></script>
|
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-1BoGv9oPfrxI6QUHqWeW6bcbK2ix8Tya2dKrHupQk3vI1XgKcSmAJWchzQghRYhG9WFlTBW6jPJBDb9lTj+gSw==" crossorigin="anonymous"></script>
|
||||||
<!--[if lt IE 10]>
|
<!--[if lt IE 10]>
|
||||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
@ -54,7 +54,7 @@ if ($QRCODE):
|
|||||||
<?php
|
<?php
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-msvuz4bHPzxA4SPt80AzVlD8DybEUb+3819GfmoyMin//9poPKN7cPp8pXgLwQUxxaxYK9bUpXj7UmbSNLU+Xg==" crossorigin="anonymous"></script>
|
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-1BoGv9oPfrxI6QUHqWeW6bcbK2ix8Tya2dKrHupQk3vI1XgKcSmAJWchzQghRYhG9WFlTBW6jPJBDb9lTj+gSw==" crossorigin="anonymous"></script>
|
||||||
<!--[if lt IE 10]>
|
<!--[if lt IE 10]>
|
||||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
Loading…
Reference in New Issue
Block a user