diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2015-02-12 16:49:31 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2015-02-12 16:50:14 +0100 |
commit | e952687dcdd5d5da7f081a7b1fea38fb9937d259 (patch) | |
tree | d65e2f4834acac95645e9e989345fc02fc07f1e2 /core | |
parent | 47b96c9fa1449509c11a5a22589d67a6b1138d20 (diff) | |
download | nextcloud-server-e952687dcdd5d5da7f081a7b1fea38fb9937d259.tar.gz nextcloud-server-e952687dcdd5d5da7f081a7b1fea38fb9937d259.zip |
Added unit test
Diffstat (limited to 'core')
-rw-r--r-- | core/js/share.js | 4 | ||||
-rw-r--r-- | core/js/tests/specs/shareSpec.js | 35 |
2 files changed, 37 insertions, 2 deletions
diff --git a/core/js/share.js b/core/js/share.js index 1e86cddb89d..e708ed587c6 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -656,7 +656,7 @@ OC.Share={ var html = '<li style="clear: both;" data-share-type="'+escapeHTML(shareType)+'" data-share-with="'+escapeHTML(shareWith)+'" title="' + escapeHTML(shareWith) + '">'; var showCrudsButton; html += '<a href="#" class="unshare"><img class="svg" alt="'+t('core', 'Unshare')+'" title="'+t('core', 'Unshare')+'" src="'+OC.imagePath('core', 'actions/delete')+'"/></a>'; - if (shareType == OC.Share.SHARE_TYPE_USER) { + if (shareType === OC.Share.SHARE_TYPE_USER) { html += '<div id="avatar-' + escapeHTML(shareWith) + '" class="avatar"></div>'; } else { html += '<div class="avatar" style="padding-right: 32px"></div>'; @@ -692,7 +692,7 @@ OC.Share={ html += '</div>'; html += '</li>'; html = $(html).appendTo('#shareWithList'); - if (shareType == OC.Share.SHARE_TYPE_USER) { + if (shareType === OC.Share.SHARE_TYPE_USER) { $('#avatar-' + escapeHTML(shareWith)).avatar(escapeHTML(shareWith), 32); } // insert cruds button into last label element diff --git a/core/js/tests/specs/shareSpec.js b/core/js/tests/specs/shareSpec.js index 7eb22261e10..21d93d4a4b0 100644 --- a/core/js/tests/specs/shareSpec.js +++ b/core/js/tests/specs/shareSpec.js @@ -26,6 +26,7 @@ describe('OC.Share tests', function() { var oldAppConfig; var loadItemStub; var autocompleteStub; + var avatarStub; beforeEach(function() { $('#testArea').append($('<div id="shareContainer"></div>')); @@ -54,6 +55,8 @@ describe('OC.Share tests', function() { var $el = $('<div></div>').data('ui-autocomplete', {}); return $el; }); + + avatarStub = sinon.stub($.fn, 'avatar'); }); afterEach(function() { /* jshint camelcase:false */ @@ -61,6 +64,7 @@ describe('OC.Share tests', function() { loadItemStub.restore(); autocompleteStub.restore(); + avatarStub.restore(); $('#dropdown').remove(); }); it('calls loadItem with the correct arguments', function() { @@ -405,6 +409,37 @@ describe('OC.Share tests', function() { }); }); }); + describe('check for avatar', function() { + beforeEach(function() { + loadItemStub.returns({ + reshare: [], + shares: [{ + id: 100, + item_source: 123, + permissions: 31, + share_type: OC.Share.SHARE_TYPE_USER, + share_with: 'user1', + share_with_displayname: 'User One' + }] + }); + OC.Share.showDropDown( + 'file', + 123, + $container, + true, + 31, + 'shared_file_name.txt' + ); + }); + it('test correct function call', function() { + expect(avatarStub.calledOnce).toEqual(true); + var args = avatarStub.getCall(0).args; + + expect($('#avatar-user1')[0]).toEqual(jasmine.anything()); + expect(args.length).toEqual(2); + expect(args[0]).toEqual('user1'); + }); + }); describe('"sharesChanged" event', function() { var autocompleteOptions; var handler; |