diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2015-05-16 14:22:10 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2015-05-27 16:22:34 +0200 |
commit | bf491183c1e2e3ad1f2cd9d42e09339b5705acd3 (patch) | |
tree | d06b11fd0a61bf0d6f64d59ba1071522f58bd5e3 /core/js/tests | |
parent | 3de945d13da0016cd8c602867ff18a33c2534418 (diff) | |
download | nextcloud-server-bf491183c1e2e3ad1f2cd9d42e09339b5705acd3.tar.gz nextcloud-server-bf491183c1e2e3ad1f2cd9d42e09339b5705acd3.zip |
Properly format remote recipients
* A list of recipients can now be properly formatted with remote shares.
Before the shares where simply shown in full in the "Shared with others"
section.
* Unit tests updated and added
Diffstat (limited to 'core/js/tests')
-rw-r--r-- | core/js/tests/specs/shareSpec.js | 93 |
1 files changed, 90 insertions, 3 deletions
diff --git a/core/js/tests/specs/shareSpec.js b/core/js/tests/specs/shareSpec.js index 33090bbda74..4e12f3bb0cf 100644 --- a/core/js/tests/specs/shareSpec.js +++ b/core/js/tests/specs/shareSpec.js @@ -1134,9 +1134,9 @@ describe('OC.Share tests', function() { $action = $file.find('.action-share>span'); expect($action.text()).toEqual(output); if (_.isString(title)) { - expect($action.find('.remoteOwner').attr('title')).toEqual(title); + expect($action.find('.remoteAddress').attr('title')).toEqual(title); } else { - expect($action.find('.remoteOwner').attr('title')).not.toBeDefined(); + expect($action.find('.remoteAddress').attr('title')).not.toBeDefined(); } expect(tipsyStub.calledOnce).toEqual(true); tipsyStub.reset(); @@ -1227,7 +1227,94 @@ describe('OC.Share tests', function() { checkIcon('filetypes/folder-public'); }); }); - // TODO: add unit tests for share recipients + + describe('displaying the recipoients', function() { + function checkRecipients(input, output, title) { + var $action; + + $file.attr('data-share-recipients', input); + OC.Share.markFileAsShared($file, true); + + $action = $file.find('.action-share>span'); + expect($action.text()).toEqual(output); + if (_.isString(title)) { + expect($action.find('.remoteAddress').attr('title')).toEqual(title); + } else if (_.isArray(title)) { + var tooltips = $action.find('.remoteAddress'); + expect(tooltips.length).toEqual(title.length); + + tooltips.each(function(i) { + expect($(this).attr('title')).toEqual(title[i]); + }); + } else { + expect($action.find('.remoteAddress').attr('title')).not.toBeDefined(); + } + expect(tipsyStub.calledOnce).toEqual(true); + tipsyStub.reset(); + } + + it('displays the local share owner as is', function() { + checkRecipients('User One', 'Shared with User One', null); + }); + it('displays the user name part of a remote recipient', function() { + checkRecipients( + 'User One@someserver.com', + 'Shared with User One@…', + 'User One@someserver.com' + ); + checkRecipients( + 'User One@someserver.com/', + 'Shared with User One@…', + 'User One@someserver.com' + ); + checkRecipients( + 'User One@someserver.com/root/of/owncloud', + 'Shared with User One@…', + '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', + 'Shared with User One@example.com', + 'User One@example.com@someserver.com' + ); + checkRecipients( + 'User One@example.com@someserver.com/', + 'Shared with User One@example.com', + 'User One@example.com@someserver.com' + ); + checkRecipients( + 'User One@example.com@someserver.com/root/of/owncloud', + 'Shared with User One@example.com', + 'User One@example.com@someserver.com' + ); + }); + it('display multiple remote recipients', function() { + checkRecipients( + 'One@someserver.com, two@otherserver.com', + 'Shared with One@…, two@…', + ['One@someserver.com', 'two@otherserver.com'] + ); + checkRecipients( + 'One@someserver.com/, two@otherserver.com', + 'Shared with One@…, two@…', + ['One@someserver.com', 'two@otherserver.com'] + ); + checkRecipients( + 'One@someserver.com/root/of/owncloud, two@otherserver.com', + 'Shared with One@…, two@…', + ['One@someserver.com', 'two@otherserver.com'] + ); + }); + it('display mixed recipients', function() { + checkRecipients( + 'One, two@otherserver.com', + 'Shared with One, two@…', + ['two@otherserver.com'] + ); + }); + }); }); }); |