mirror of
https://github.com/nextcloud/server.git
synced 2026-02-20 00:12:30 -05:00
Added unit test
This commit is contained in:
parent
47b96c9fa1
commit
e952687dcd
2 changed files with 37 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue