diff options
author | Robin Appelman <icewind@owncloud.com> | 2014-10-31 15:22:08 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2014-10-31 15:22:08 +0100 |
commit | 83126ab67596a29200e1624088801312935e4580 (patch) | |
tree | 86cccd96f405b3bb0557763d822175112f32395a /apps/files_sharing/tests/js | |
parent | 307071cfec088c2690c12a686578b49647ba5840 (diff) | |
download | nextcloud-server-83126ab67596a29200e1624088801312935e4580.tar.gz nextcloud-server-83126ab67596a29200e1624088801312935e4580.zip |
Add unit tests
Diffstat (limited to 'apps/files_sharing/tests/js')
-rw-r--r-- | apps/files_sharing/tests/js/sharedfilelistSpec.js | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/apps/files_sharing/tests/js/sharedfilelistSpec.js b/apps/files_sharing/tests/js/sharedfilelistSpec.js index 41c8a1f05d8..812f30d75db 100644 --- a/apps/files_sharing/tests/js/sharedfilelistSpec.js +++ b/apps/files_sharing/tests/js/sharedfilelistSpec.js @@ -551,4 +551,89 @@ describe('OCA.Sharing.FileList tests', function() { expect($tr.find('.nametext').text().trim()).toEqual('local name.txt'); }); }); + describe('setting share permissions for files', function () { + beforeEach(function () { + + var $content = $('<div id="content"></div>'); + $('#testArea').append($content); + // dummy file list + var $div = $( + '<div>' + + '<table id="filestable">' + + '<thead></thead>' + + '<tbody id="fileList"></tbody>' + + '</table>' + + '</div>'); + $('#content').append($div); + + fileList = new OCA.Files.FileList( + $div, { + fileActions: fileActions + } + ); + }); + + it('external storage root folder', function () { + var $tr; + OC.Share.statuses = {1: {link: false, path: '/subdir'}}; + fileList.setFiles([{ + id: 1, + type: 'dir', + name: 'One.txt', + path: '/subdir', + mimetype: 'text/plain', + size: 12, + permissions: OC.PERMISSION_READ, + etag: 'abc', + shareOwner: 'User One', + recipients: 'User Two', + mountType: 'external-root' + }]); + $tr = fileList.$el.find('tr:first'); + + expect(parseInt($tr.attr('data-share-permissions'), 10)).toEqual(OC.PERMISSION_ALL - OC.PERMISSION_SHARE); + }); + + it('external storage root folder reshare', function () { + var $tr; + OC.Share.statuses = {1: {link: false, path: '/subdir'}}; + fileList.setFiles([{ + id: 1, + type: 'dir', + name: 'One.txt', + path: '/subdir', + mimetype: 'text/plain', + size: 12, + permissions: OC.PERMISSION_READ + OC.PERMISSION_SHARE, + etag: 'abc', + shareOwner: 'User One', + recipients: 'User Two', + mountType: 'external-root' + }]); + $tr = fileList.$el.find('tr:first'); + + expect(parseInt($tr.attr('data-share-permissions'), 10)).toEqual(OC.PERMISSION_ALL); + }); + + it('external storage root folder file', function () { + var $tr; + OC.Share.statuses = {1: {link: false, path: '/subdir'}}; + fileList.setFiles([{ + id: 1, + type: 'file', + name: 'One.txt', + path: '/subdir', + mimetype: 'text/plain', + size: 12, + permissions: OC.PERMISSION_READ, + etag: 'abc', + shareOwner: 'User One', + recipients: 'User Two', + mountType: 'external-root' + }]); + $tr = fileList.$el.find('tr:first'); + + expect(parseInt($tr.attr('data-share-permissions'), 10)).toEqual(OC.PERMISSION_ALL - OC.PERMISSION_SHARE - OC.PERMISSION_DELETE); + }); + }); }); |