@ -68,6 +68,12 @@ describe('OCA.Files.MainFileInfoDetailView tests', function() {
. toEqual ( OC . getProtocol ( ) + '://' + OC . getHost ( ) + OC . generateUrl ( '/f/5' ) ) ;
} ) ;
it ( 'displays favorite icon' , function ( ) {
fileActions . registerAction ( {
name : 'Favorite' ,
mime : 'all' ,
permissions : OC . PERMISSION _READ
} ) ;
testFileInfo . set ( 'tags' , [ OC . TAG _FAVORITE ] ) ;
view . setFileInfo ( testFileInfo ) ;
expect ( view . $el . find ( '.action-favorite > span' ) . hasClass ( 'icon-starred' ) ) . toEqual ( true ) ;
@ -78,6 +84,15 @@ describe('OCA.Files.MainFileInfoDetailView tests', function() {
expect ( view . $el . find ( '.action-favorite > span' ) . hasClass ( 'icon-starred' ) ) . toEqual ( false ) ;
expect ( view . $el . find ( '.action-favorite > span' ) . hasClass ( 'icon-star' ) ) . toEqual ( true ) ;
} ) ;
it ( 'does not display favorite icon if favorite action is not available' , function ( ) {
testFileInfo . set ( 'tags' , [ OC . TAG _FAVORITE ] ) ;
view . setFileInfo ( testFileInfo ) ;
expect ( view . $el . find ( '.action-favorite' ) . length ) . toEqual ( 0 ) ;
testFileInfo . set ( 'tags' , [ ] ) ;
view . setFileInfo ( testFileInfo ) ;
expect ( view . $el . find ( '.action-favorite' ) . length ) . toEqual ( 0 ) ;
} ) ;
it ( 'displays mime icon' , function ( ) {
// File
var lazyLoadPreviewStub = sinon . stub ( fileList , 'lazyLoadPreview' ) ;
@ -183,6 +198,13 @@ describe('OCA.Files.MainFileInfoDetailView tests', function() {
expect ( view . $el . find ( '.fileName h3' ) . attr ( 'title' ) ) . toEqual ( 'hello.txt' ) ;
} ) ;
it ( 'rerenders when changes are made on the model' , function ( ) {
// Show the "Favorite" icon
fileActions . registerAction ( {
name : 'Favorite' ,
mime : 'all' ,
permissions : OC . PERMISSION _READ
} ) ;
view . setFileInfo ( testFileInfo ) ;
testFileInfo . set ( 'tags' , [ OC . TAG _FAVORITE ] ) ;
@ -196,11 +218,19 @@ describe('OCA.Files.MainFileInfoDetailView tests', function() {
expect ( view . $el . find ( '.action-favorite > span' ) . hasClass ( 'icon-star' ) ) . toEqual ( true ) ;
} ) ;
it ( 'unbinds change listener from model' , function ( ) {
// Show the "Favorite" icon
fileActions . registerAction ( {
name : 'Favorite' ,
mime : 'all' ,
permissions : OC . PERMISSION _READ
} ) ;
view . setFileInfo ( testFileInfo ) ;
view . setFileInfo ( new OCA . Files . FileInfoModel ( {
id : 999 ,
name : 'test.txt' ,
path : '/'
path : '/' ,
permissions : 31
} ) ) ;
// set value on old model