diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2019-10-16 21:46:31 +0200 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2019-10-29 13:20:08 +0100 |
commit | a48359ac024b1b0dbfea2dc3deb93607b0dbf329 (patch) | |
tree | ba30df4cb8b31b59cc56d6e08bfb8eb8a255ccfd /apps/files_sharing/tests | |
parent | 480691a56951e85bf32c86e43e2d3e93dad03560 (diff) | |
download | nextcloud-server-a48359ac024b1b0dbfea2dc3deb93607b0dbf329.tar.gz nextcloud-server-a48359ac024b1b0dbfea2dc3deb93607b0dbf329.zip |
Adjust unit tests to new OCA.Sidebar
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files_sharing/tests')
-rw-r--r-- | apps/files_sharing/tests/js/shareSpec.js | 207 |
1 files changed, 0 insertions, 207 deletions
diff --git a/apps/files_sharing/tests/js/shareSpec.js b/apps/files_sharing/tests/js/shareSpec.js index a4aa6eea746..061c789c141 100644 --- a/apps/files_sharing/tests/js/shareSpec.js +++ b/apps/files_sharing/tests/js/shareSpec.js @@ -234,198 +234,6 @@ describe('OCA.Sharing.Util tests', function() { expect($tr.find('.action-share').length).toEqual(0); }); }); - describe('Share action', function() { - var shareTab; - - function makeDummyShareItem(displayName) { - return { - share_with_displayname: displayName - }; - } - - beforeEach(function() { - // make it look like not the "All files" list - fileList.id = 'test'; - shareTab = fileList._detailsView._tabViews[0]; - }); - afterEach(function() { - shareTab = null; - }); - it('clicking share action opens sidebar and share tab', function() { - var showDetailsViewStub = sinon.stub(fileList, 'showDetailsView'); - - fileList.setFiles([{ - id: 1, - type: 'file', - name: 'One.txt', - path: '/subdir', - mimetype: 'text/plain', - size: 12, - permissions: OC.PERMISSION_ALL, - etag: 'abc' - }]); - - var $tr = fileList.$el.find('tr:first'); - $tr.find('.action-share').click(); - - expect(showDetailsViewStub.calledOnce).toEqual(true); - expect(showDetailsViewStub.getCall(0).args[0]).toEqual('One.txt'); - expect(showDetailsViewStub.getCall(0).args[1]).toEqual('shareTabView'); - - showDetailsViewStub.restore(); - }); - it('adds share icon after sharing a non-shared file', function() { - var $action, $tr; - OC.Share.statuses = {}; - fileList.setFiles([{ - id: 1, - type: 'file', - name: 'One.txt', - path: '/subdir', - mimetype: 'text/plain', - size: 12, - permissions: OC.PERMISSION_ALL, - etag: 'abc' - }]); - $action = fileList.$el.find('tbody tr:first .action-share'); - $tr = fileList.$el.find('tr:first'); - - $tr.find('.action-share').click(); - - // simulate updating shares - shareTab._dialog.model.set({ - shares: [ - {share_with_displayname: 'User One', share_with: 'User One'}, - {share_with_displayname: 'User Two', share_with: 'User Two'}, - {share_with_displayname: 'Group One', share_with: 'Group One'}, - {share_with_displayname: 'Group Two', share_with: 'Group Two'} - ] - }); - - expect($action.text().trim()).toEqual('Shared with Group One Shared with Group Two Shared with User One Shared with User Two'); - expect($action.find('.icon').hasClass('icon-shared')).toEqual(true); - expect($action.find('.icon').hasClass('icon-public')).toEqual(false); - }); - it('updates share icon after updating shares of a file', function() { - var $action, $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_ALL, - etag: 'abc' - }]); - $action = fileList.$el.find('tbody tr:first .action-share'); - $tr = fileList.$el.find('tr:first'); - - $tr.find('.action-share').click(); - - // simulate updating shares - shareTab._dialog.model.set({ - shares: [ - {share_with_displayname: 'User One', share_with: 'User One'}, - {share_with_displayname: 'User Two', share_with: 'User Two'}, - {share_with_displayname: 'User Three', share_with: 'User Three'} - ] - }); - - expect($action.text().trim()).toEqual('Shared with User One Shared with User Three Shared with User Two'); - expect($action.find('.icon').hasClass('icon-shared')).toEqual(true); - expect($action.find('.icon').hasClass('icon-public')).toEqual(false); - }); - it('removes share icon after removing all shares from a file', function() { - var $action, $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_ALL, - etag: 'abc', - recipients: 'User One, User Two' - }]); - $action = fileList.$el.find('tbody tr:first .action-share'); - $tr = fileList.$el.find('tr:first'); - - $tr.find('.action-share').click(); - - // simulate updating shares - shareTab._dialog.model.set({ - shares: [] - }); - - expect($tr.attr('data-share-recipient-data')).not.toBeDefined(); - }); - it('keep share text after updating reshare', function() { - var $action, $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_ALL, - etag: 'abc', - shareOwner: 'User One', - shareOwnerId: 'User One' - }]); - $action = fileList.$el.find('tbody tr:first .action-share'); - $tr = fileList.$el.find('tr:first'); - - $tr.find('.action-share').click(); - - // simulate updating shares - shareTab._dialog.model.set({ - shares: [{share_with_displayname: 'User Two'}] - }); - - expect($action.find('>span').text().trim()).toEqual('Shared by User One'); - expect($action.find('.icon').hasClass('icon-shared')).toEqual(false); - expect($action.find('.icon').hasClass('icon-public')).toEqual(false); - }); - it('keep share text after unsharing reshare', function() { - var $action, $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_ALL, - etag: 'abc', - shareOwner: 'User One', - shareOwnerId: 'User One', - recipients: 'User Two', - recipientData: {'User Two': 'User Two'} - }]); - $action = fileList.$el.find('tbody tr:first .action-share'); - $tr = fileList.$el.find('tr:first'); - - $tr.find('.action-share').click(); - - // simulate updating shares - shareTab._dialog.model.set({ - shares: [] - }); - - expect($tr.attr('data-share-recipient-data')).not.toBeDefined(); - - expect($action.find('>span').text().trim()).toEqual('Shared by User One'); - expect($action.find('.icon').hasClass('icon-shared')).toEqual(false); - expect($action.find('.icon').hasClass('icon-public')).toEqual(false); - }); - }); describe('Excluded lists', function() { function createListThenAttach(listId) { var fileActions = new OCA.Files.FileActions(); @@ -513,20 +321,5 @@ describe('OCA.Sharing.Util tests', function() { afterEach(function() { shareTabSpy.restore(); }); - - it('updates fileInfoModel when shares changed', function() { - var changeHandler = sinon.stub(); - fileInfoModel.on('change', changeHandler); - - shareTabSpy.getCall(0).returnValue.trigger('sharesChanged', shareModel); - - expect(changeHandler.calledOnce).toEqual(true); - expect(changeHandler.getCall(0).args[0].changed).toEqual({ - shareTypes: [ - OC.Share.SHARE_TYPE_USER, - OC.Share.SHARE_TYPE_REMOTE - ] - }); - }); }); }); |