Skip to content

Commit 9a6da8e

Browse files
committed
Extended avatar unit tests
1 parent 90218dc commit 9a6da8e

File tree

1 file changed

+61
-14
lines changed

1 file changed

+61
-14
lines changed

core/js/tests/specs/shareSpec.js

Lines changed: 61 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ describe('OC.Share tests', function() {
2626
var oldAppConfig;
2727
var loadItemStub;
2828
var autocompleteStub;
29+
var oldEnableAvatars;
2930
var avatarStub;
3031

3132
beforeEach(function() {
@@ -56,6 +57,8 @@ describe('OC.Share tests', function() {
5657
return $el;
5758
});
5859

60+
oldEnableAvatars = oc_config.enable_avatars;
61+
oc_config.enable_avatars = false;
5962
avatarStub = sinon.stub($.fn, 'avatar');
6063
});
6164
afterEach(function() {
@@ -65,6 +68,7 @@ describe('OC.Share tests', function() {
6568

6669
autocompleteStub.restore();
6770
avatarStub.restore();
71+
oc_config.enable_avatars = oldEnableAvatars;
6872
$('#dropdown').remove();
6973
});
7074
it('calls loadItem with the correct arguments', function() {
@@ -420,24 +424,67 @@ describe('OC.Share tests', function() {
420424
share_type: OC.Share.SHARE_TYPE_USER,
421425
share_with: 'user1',
422426
share_with_displayname: 'User One'
427+
},{
428+
id: 101,
429+
item_source: 123,
430+
permissions: 31,
431+
share_type: OC.Share.SHARE_TYPE_GROUP,
432+
share_with: 'group',
433+
share_with_displayname: 'group'
423434
}]
424435
});
425-
OC.Share.showDropDown(
426-
'file',
427-
123,
428-
$container,
429-
true,
430-
31,
431-
'shared_file_name.txt'
432-
);
433436
});
434-
it('test correct function call', function() {
435-
expect(avatarStub.calledOnce).toEqual(true);
436-
var args = avatarStub.getCall(0).args;
437437

438-
expect($('#avatar-user1').length).toEqual(1);
439-
expect(args.length).toEqual(2);
440-
expect(args[0]).toEqual('user1');
438+
describe('avatars enabled', function() {
439+
beforeEach(function() {
440+
oc_config.enable_avatars = true;
441+
OC.Share.showDropDown(
442+
'file',
443+
123,
444+
$container,
445+
true,
446+
31,
447+
'shared_file_name.txt'
448+
);
449+
});
450+
451+
afterEach(function() {
452+
oc_config.enable_avatars = false;
453+
});
454+
455+
it('test correct function call', function() {
456+
expect(avatarStub.calledOnce).toEqual(true);
457+
var args = avatarStub.getCall(0).args;
458+
459+
460+
expect($('#shareWithList').children().length).toEqual(2);
461+
462+
expect($('#avatar-user1').length).toEqual(1);
463+
expect(args.length).toEqual(2);
464+
expect(args[0]).toEqual('user1');
465+
});
466+
467+
it('test no avatar for groups', function() {
468+
expect($('#shareWithList').children().length).toEqual(2);
469+
expect($('#shareWithList li:nth-child(2) .avatar').attr('id')).not.toBeDefined();
470+
});
471+
});
472+
473+
describe('avatars disabled', function() {
474+
beforeEach(function() {
475+
OC.Share.showDropDown(
476+
'file',
477+
123,
478+
$container,
479+
true,
480+
31,
481+
'shared_file_name.txt'
482+
);
483+
});
484+
485+
it('no avatar classes', function() {
486+
expect($('.avatar').length).toEqual(0);
487+
});
441488
});
442489
});
443490
describe('"sharesChanged" event', function() {

0 commit comments

Comments
 (0)