@@ -28,6 +28,7 @@ describe('OC.Share tests', function() {
28
28
var autocompleteStub ;
29
29
var oldEnableAvatars ;
30
30
var avatarStub ;
31
+ var placeholderStub ;
31
32
32
33
beforeEach ( function ( ) {
33
34
$ ( '#testArea' ) . append ( $ ( '<div id="shareContainer"></div>' ) ) ;
@@ -60,6 +61,7 @@ describe('OC.Share tests', function() {
60
61
oldEnableAvatars = oc_config . enable_avatars ;
61
62
oc_config . enable_avatars = false ;
62
63
avatarStub = sinon . stub ( $ . fn , 'avatar' ) ;
64
+ placeholderStub = sinon . stub ( $ . fn , 'imageplaceholder' ) ;
63
65
} ) ;
64
66
afterEach ( function ( ) {
65
67
/* jshint camelcase:false */
@@ -68,6 +70,7 @@ describe('OC.Share tests', function() {
68
70
69
71
autocompleteStub . restore ( ) ;
70
72
avatarStub . restore ( ) ;
73
+ placeholderStub . restore ( ) ;
71
74
oc_config . enable_avatars = oldEnableAvatars ;
72
75
$ ( '#dropdown' ) . remove ( ) ;
73
76
} ) ;
@@ -416,7 +419,12 @@ describe('OC.Share tests', function() {
416
419
describe ( 'check for avatar' , function ( ) {
417
420
beforeEach ( function ( ) {
418
421
loadItemStub . returns ( {
419
- reshare : [ ] ,
422
+ reshare : {
423
+ share_type : OC . Share . SHARE_TYPE_USER ,
424
+ uid_owner : 'owner' ,
425
+ displayname_owner : 'Owner' ,
426
+ permissions : 31
427
+ } ,
420
428
shares : [ {
421
429
id : 100 ,
422
430
item_source : 123 ,
@@ -431,6 +439,14 @@ describe('OC.Share tests', function() {
431
439
share_type : OC . Share . SHARE_TYPE_GROUP ,
432
440
share_with : 'group' ,
433
441
share_with_displayname : 'group'
442
+ } , {
443
+ id : 102 ,
444
+ item_source : 123 ,
445
+ permissions : 31 ,
446
+ share_type : OC . Share . SHARE_TYPE_REMOTE ,
447
+ share_with :
'[email protected] /baz' ,
448
+ share_with_displayname :
'[email protected] /baz'
449
+
434
450
} ]
435
451
} ) ;
436
452
} ) ;
@@ -452,21 +468,35 @@ describe('OC.Share tests', function() {
452
468
oc_config . enable_avatars = false ;
453
469
} ) ;
454
470
455
- it ( 'test correct function call' , function ( ) {
456
- expect ( avatarStub . calledOnce ) . toEqual ( true ) ;
457
- var args = avatarStub . getCall ( 0 ) . args ;
458
-
471
+ it ( 'test correct function calls' , function ( ) {
472
+ expect ( avatarStub . calledTwice ) . toEqual ( true ) ;
473
+ expect ( placeholderStub . calledTwice ) . toEqual ( true ) ;
474
+ expect ( $ ( '#shareWithList' ) . children ( ) . length ) . toEqual ( 3 ) ;
475
+ expect ( $ ( '.avatar' ) . length ) . toEqual ( 4 ) ;
476
+ } ) ;
459
477
460
- expect ( $ ( '#shareWithList' ) . children ( ) . length ) . toEqual ( 2 ) ;
478
+ it ( 'test avatar owner' , function ( ) {
479
+ var args = avatarStub . getCall ( 0 ) . args ;
480
+ expect ( args . length ) . toEqual ( 2 ) ;
481
+ expect ( args [ 0 ] ) . toEqual ( 'owner' ) ;
482
+ } ) ;
461
483
462
- expect ( $ ( '.avatar[data-user="user1"]' ) . length ) . toEqual ( 1 ) ;
484
+ it ( 'test avatar user' , function ( ) {
485
+ var args = avatarStub . getCall ( 1 ) . args ;
463
486
expect ( args . length ) . toEqual ( 2 ) ;
464
487
expect ( args [ 0 ] ) . toEqual ( 'user1' ) ;
465
488
} ) ;
466
489
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 ( ) ;
490
+ it ( 'test avatar for groups' , function ( ) {
491
+ var args = placeholderStub . getCall ( 0 ) . args ;
492
+ expect ( args . length ) . toEqual ( 1 ) ;
493
+ expect ( args [ 0 ] ) . toEqual ( 'group ' + OC . Share . SHARE_TYPE_GROUP ) ;
494
+ } ) ;
495
+
496
+ it ( 'test avatar for remotes' , function ( ) {
497
+ var args = placeholderStub . getCall ( 1 ) . args ;
498
+ expect ( args . length ) . toEqual ( 1 ) ;
499
+ expect ( args [ 0 ] ) . toEqual ( '[email protected] /baz ' + OC . Share . SHARE_TYPE_REMOTE ) ;
470
500
} ) ;
471
501
} ) ;
472
502
@@ -484,6 +514,8 @@ describe('OC.Share tests', function() {
484
514
485
515
it ( 'no avatar classes' , function ( ) {
486
516
expect ( $ ( '.avatar' ) . length ) . toEqual ( 0 ) ;
517
+ expect ( avatarStub . callCount ) . toEqual ( 0 ) ;
518
+ expect ( placeholderStub . callCount ) . toEqual ( 0 ) ;
487
519
} ) ;
488
520
} ) ;
489
521
} ) ;
0 commit comments