adjust, fix and extend tests
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
parent
4247936dd6
commit
3a1d8fa45f
|
@ -197,24 +197,20 @@ OC.Share = _.extend(OC.Share || {}, {
|
|||
delete OC.Share.statuses[itemSource];
|
||||
}
|
||||
},
|
||||
_formatRegularShare: function(shareWith, shareWithDisplayName, message) {
|
||||
// display avatar of the user
|
||||
var avatar = '<span class="avatar" data-username="' + escapeHTML(shareWith) + '" title="' + message + " " + escapeHTML(shareWithDisplayName) + '"></span>';
|
||||
var hidden = '<span class="hidden-visually">' + message + ' ' + escapeHTML(shareWithDisplayName) + '</span> ';
|
||||
return avatar + hidden;
|
||||
},
|
||||
/**
|
||||
* Format a remote address
|
||||
*
|
||||
* @param {String} remoteAddress full remote share
|
||||
* @param {String} shareWith userid, full remote share, or whatever
|
||||
* @param {String} shareWithDisplayName
|
||||
* @param {String} message
|
||||
* @return {String} HTML code to display
|
||||
*/
|
||||
_formatRemoteShare: function(remoteAddress, message) {
|
||||
var parts = this._REMOTE_OWNER_REGEXP.exec(remoteAddress);
|
||||
_formatRemoteShare: function(shareWith, shareWithDisplayName, message) {
|
||||
var parts = this._REMOTE_OWNER_REGEXP.exec(shareWith);
|
||||
if (!parts) {
|
||||
// display avatar of the user
|
||||
var avatar = '<span class="avatar" data-username="' + escapeHTML(remoteAddress) + '" title="' + message + " " + escapeHTML(remoteAddress) + '"></span>';
|
||||
var hidden = '<span class="hidden-visually">' + message + ' ' + escapeHTML(remoteAddress) + '</span> ';
|
||||
var avatar = '<span class="avatar" data-username="' + escapeHTML(shareWith) + '" title="' + message + " " + escapeHTML(shareWithDisplayName) + '"></span>';
|
||||
var hidden = '<span class="hidden-visually">' + message + ' ' + escapeHTML(shareWithDisplayName) + '</span> ';
|
||||
return avatar + hidden;
|
||||
}
|
||||
|
||||
|
@ -250,7 +246,7 @@ OC.Share = _.extend(OC.Share || {}, {
|
|||
_formatShareList: function(recipients) {
|
||||
var _parent = this;
|
||||
return $.map(recipients, function(shareWithDisplayName, shareWith) {
|
||||
return _parent._formatRegularShare(shareWith, shareWithDisplayName, t('core', 'Shared with'));
|
||||
return _parent._formatRemoteShare(shareWith, shareWithDisplayName, t('core', 'Shared with'));
|
||||
});
|
||||
},
|
||||
/**
|
||||
|
@ -304,7 +300,7 @@ OC.Share = _.extend(OC.Share || {}, {
|
|||
// even if reshared, only show "Shared by"
|
||||
if (ownerId) {
|
||||
message = t('core', 'Shared by');
|
||||
avatars = this._formatRegularShare(ownerId, owner, message);
|
||||
avatars = this._formatRemoteShare(ownerId, owner, message);
|
||||
} else if (recipients) {
|
||||
avatars = this._formatShareList(recipients);
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ describe('OC.Share tests', function() {
|
|||
var $action;
|
||||
|
||||
$file.attr('data-share-owner', input);
|
||||
$file.attr('data-share-owner-id', input);
|
||||
OC.Share.markFileAsShared($file);
|
||||
|
||||
$action = $file.find('.action-share>span').parent();
|
||||
|
@ -119,6 +120,7 @@ describe('OC.Share tests', function() {
|
|||
it('shows a shared folder icon for folders shared with the current user', function() {
|
||||
$file.attr('data-type', 'dir');
|
||||
$file.attr('data-share-owner', 'someoneelse');
|
||||
$file.attr('data-share-owner-id', 'someoneelse');
|
||||
OC.Share.markFileAsShared($file);
|
||||
|
||||
checkIcon('filetypes/folder-shared');
|
||||
|
@ -155,7 +157,9 @@ describe('OC.Share tests', function() {
|
|||
function checkRecipients(input, output, title) {
|
||||
var $action;
|
||||
|
||||
$file.attr('data-share-recipients', input);
|
||||
var concatenated = _.values(input).join(', ');
|
||||
$file.attr('data-share-recipients', concatenated);
|
||||
$file.attr('data-share-recipient-data', JSON.stringify(input));
|
||||
OC.Share.markFileAsShared($file, true);
|
||||
|
||||
$action = $file.find('.action-share>span').parent();
|
||||
|
@ -177,66 +181,89 @@ describe('OC.Share tests', function() {
|
|||
}
|
||||
|
||||
it('displays the local share owner as is', function() {
|
||||
checkRecipients('User One', 'Shared with User One', null);
|
||||
checkRecipients({'User One': 'User One'}, 'Shared with User One', null);
|
||||
});
|
||||
it('displays the user name part of a remote recipient', function() {
|
||||
checkRecipients(
|
||||
'User One@someserver.com',
|
||||
{'User One@someserver.com': 'User One@someserver.com'},
|
||||
'User One@…',
|
||||
'Shared with User One@someserver.com'
|
||||
);
|
||||
checkRecipients(
|
||||
'User One@someserver.com/',
|
||||
'{User One@someserver.com/: User One@someserver.com/}',
|
||||
'User One@…',
|
||||
'Shared with User One@someserver.com'
|
||||
);
|
||||
checkRecipients(
|
||||
'User One@someserver.com/root/of/owncloud',
|
||||
{'User One@someserver.com/root/of/owncloud': 'User One@someserver.com/root/of/owncloud'},
|
||||
'User One@…',
|
||||
'Shared with User One@someserver.com'
|
||||
);
|
||||
});
|
||||
it('displays the user name part with domain of a remote share owner', function() {
|
||||
checkRecipients(
|
||||
'User One@example.com@someserver.com',
|
||||
{'User One@example.com@someserver.com': 'User One@example.com@someserver.com'},
|
||||
'User One@example.com',
|
||||
'Shared with User One@example.com@someserver.com'
|
||||
);
|
||||
checkRecipients(
|
||||
'User One@example.com@someserver.com/',
|
||||
{'User One@example.com@someserver.com/': 'User One@example.com@someserver.com/'},
|
||||
'User One@example.com',
|
||||
'Shared with User One@example.com@someserver.com'
|
||||
);
|
||||
checkRecipients(
|
||||
'User One@example.com@someserver.com/root/of/owncloud',
|
||||
{'User One@example.com@someserver.com/root/of/nextcloud': 'User One@example.com@someserver.com/root/of/nextcloud'},
|
||||
'User One@example.com',
|
||||
'Shared with User One@example.com@someserver.com'
|
||||
);
|
||||
});
|
||||
it('display multiple remote recipients', function() {
|
||||
checkRecipients(
|
||||
'One@someserver.com, two@otherserver.com',
|
||||
{
|
||||
'One@someserver.com': 'One@someserver.com',
|
||||
'two@otherserver.com': 'two@otherserver.com'
|
||||
},
|
||||
'One@… two@…',
|
||||
['Shared with One@someserver.com', 'Shared with two@otherserver.com']
|
||||
);
|
||||
checkRecipients(
|
||||
'One@someserver.com/, two@otherserver.com',
|
||||
{
|
||||
'One@someserver.com/': 'One@someserver.com/',
|
||||
'two@otherserver.com': 'two@otherserver.com'
|
||||
},
|
||||
'One@… two@…',
|
||||
['Shared with One@someserver.com', 'Shared with two@otherserver.com']
|
||||
);
|
||||
checkRecipients(
|
||||
'One@someserver.com/root/of/owncloud, two@otherserver.com',
|
||||
{
|
||||
'One@someserver.com/root/of/owncloud': 'One@someserver.com/root/of/owncloud',
|
||||
'two@otherserver.com': 'two@otherserver.com'
|
||||
},
|
||||
'One@… two@…',
|
||||
['Shared with One@someserver.com', 'Shared with two@otherserver.com']
|
||||
);
|
||||
});
|
||||
it('display mixed recipients', function() {
|
||||
checkRecipients(
|
||||
'One, two@otherserver.com',
|
||||
{
|
||||
'One': 'One',
|
||||
'two@otherserver.com': 'two@otherserver.com'
|
||||
},
|
||||
'Shared with One two@…',
|
||||
['Shared with two@otherserver.com']
|
||||
);
|
||||
});
|
||||
it('display multiple with divergent displaynames', function() {
|
||||
checkRecipients(
|
||||
{
|
||||
'One': 'Yoko Ono',
|
||||
'two@otherserver.com': 'two@otherserver.com',
|
||||
'Three': 'Green, Mina'
|
||||
},
|
||||
'Shared with Yoko Ono two@… Shared with Green, Mina',
|
||||
['Shared with two@otherserver.com']
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue