mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2025-07-20 05:33:17 -04:00
Allow multiple files
This commit is contained in:
parent
6ff08b6884
commit
095a5be0b6
7 changed files with 256 additions and 191 deletions
|
@ -27,11 +27,14 @@ describe('AttachmentViewer', function () {
|
|||
prefix = prefix.replace(/%(s|d)/g, '%%');
|
||||
postfix = postfix.replace(/%(s|d)/g, '%%');
|
||||
$('body').html(
|
||||
'<div id="attachment" role="alert" class="hidden alert ' +
|
||||
'alert-info"><span class="glyphicon glyphicon-download-' +
|
||||
'alt" aria-hidden="true"></span> <a class="alert-link">' +
|
||||
'Download attachment</a></div><div id="attachmentPrevie' +
|
||||
'w" class="hidden"></div>'
|
||||
'<div id="attachmentPreview" class="col-md-12 text-center hidden"></div>' +
|
||||
'<div id="attachment" class="hidden"></div>' +
|
||||
'<div id="templates">' +
|
||||
'<div id="attachmenttemplate" role="alert" class="attachment hidden alert alert-info">' +
|
||||
'<span class="glyphicon glyphicon-download-alt" aria-hidden="true"></span>' +
|
||||
'<a class="alert-link">Download attachment</a>' +
|
||||
'</div>' +
|
||||
'</div>'
|
||||
);
|
||||
// mock createObjectURL for jsDOM
|
||||
if (typeof window.URL.createObjectURL === 'undefined') {
|
||||
|
@ -44,9 +47,12 @@ describe('AttachmentViewer', function () {
|
|||
)
|
||||
}
|
||||
$.PrivateBin.AttachmentViewer.init();
|
||||
$.PrivateBin.Model.init();
|
||||
results.push(
|
||||
!$.PrivateBin.AttachmentViewer.hasAttachment() &&
|
||||
$('#attachment').hasClass('hidden') &&
|
||||
$('#attachment').children().length === 0 &&
|
||||
$('#attachmenttemplate').hasClass('hidden') &&
|
||||
$('#attachmentPreview').hasClass('hidden')
|
||||
);
|
||||
global.atob = common.atob;
|
||||
|
@ -55,19 +61,21 @@ describe('AttachmentViewer', function () {
|
|||
} else {
|
||||
$.PrivateBin.AttachmentViewer.setAttachment(data);
|
||||
}
|
||||
// beyond this point we will get the blob URL instead of the data
|
||||
// // beyond this point we will get the blob URL instead of the data
|
||||
data = window.URL.createObjectURL(data);
|
||||
const attachment = $.PrivateBin.AttachmentViewer.getAttachment();
|
||||
const attachment = $.PrivateBin.AttachmentViewer.getAttachments();
|
||||
results.push(
|
||||
$.PrivateBin.AttachmentViewer.hasAttachment() &&
|
||||
$('#attachment').hasClass('hidden') &&
|
||||
$('#attachment').children().length > 0 &&
|
||||
$('#attachmentPreview').hasClass('hidden') &&
|
||||
attachment[0] === data &&
|
||||
attachment[1] === filename
|
||||
attachment[0][0] === data &&
|
||||
attachment[0][1] === filename
|
||||
);
|
||||
$.PrivateBin.AttachmentViewer.showAttachment();
|
||||
results.push(
|
||||
!$('#attachment').hasClass('hidden') &&
|
||||
$('#attachment').children().length > 0 &&
|
||||
(previewSupported ? !$('#attachmentPreview').hasClass('hidden') : $('#attachmentPreview').hasClass('hidden'))
|
||||
);
|
||||
$.PrivateBin.AttachmentViewer.hideAttachment();
|
||||
|
@ -85,7 +93,7 @@ describe('AttachmentViewer', function () {
|
|||
(previewSupported ? !$('#attachmentPreview').hasClass('hidden') : $('#attachmentPreview').hasClass('hidden'))
|
||||
);
|
||||
let element = $('<div>');
|
||||
$.PrivateBin.AttachmentViewer.moveAttachmentTo(element, prefix + '%s' + postfix);
|
||||
$.PrivateBin.AttachmentViewer.moveAttachmentTo(element, attachment[0], prefix + '%s' + postfix);
|
||||
// messageIDs with links get a relaxed treatment
|
||||
if (prefix.indexOf('<a') === -1 && postfix.indexOf('<a') === -1) {
|
||||
result = $('<textarea>').text((prefix + filename + postfix)).text();
|
||||
|
@ -99,16 +107,17 @@ describe('AttachmentViewer', function () {
|
|||
}
|
||||
if (filename.length) {
|
||||
results.push(
|
||||
element.children()[0].href === data &&
|
||||
element.children()[0].getAttribute('download') === filename &&
|
||||
element.children()[0].text === result
|
||||
element.find('a')[0].href === data &&
|
||||
element.find('a')[0].getAttribute('download') === filename &&
|
||||
element.find('a')[0].text === result
|
||||
);
|
||||
} else {
|
||||
results.push(element.children()[0].href === data);
|
||||
results.push(element.find('a')[0].href === data);
|
||||
}
|
||||
$.PrivateBin.AttachmentViewer.removeAttachment();
|
||||
results.push(
|
||||
$('#attachment').hasClass('hidden') &&
|
||||
$('#attachment').children().length === 0 &&
|
||||
$('#attachmentPreview').hasClass('hidden')
|
||||
);
|
||||
clean();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue