diff options
author | Vincent Petry <pvince81@owncloud.com> | 2016-05-04 11:17:53 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2016-05-06 16:46:59 +0200 |
commit | fdeafef6a08c45f8b45ab9fac303e3bffc3607b0 (patch) | |
tree | a96ca5a4bfeca3b5a2a330c125e7f6738f67b10a /apps/files/tests | |
parent | 093e9dd4225e6681140523c75bfc20809cd6d651 (diff) | |
download | nextcloud-server-fdeafef6a08c45f8b45ab9fac303e3bffc3607b0.tar.gz nextcloud-server-fdeafef6a08c45f8b45ab9fac303e3bffc3607b0.zip |
Auto-add fileid in URL for currently displayed folder
Diffstat (limited to 'apps/files/tests')
-rw-r--r-- | apps/files/tests/js/appSpec.js | 20 | ||||
-rw-r--r-- | apps/files/tests/js/filelistSpec.js | 9 |
2 files changed, 29 insertions, 0 deletions
diff --git a/apps/files/tests/js/appSpec.js b/apps/files/tests/js/appSpec.js index dce513339f0..3070d687fc5 100644 --- a/apps/files/tests/js/appSpec.js +++ b/apps/files/tests/js/appSpec.js @@ -22,6 +22,7 @@ describe('OCA.Files.App tests', function() { var App = OCA.Files.App; var pushStateStub; + var replaceStateStub; var parseUrlQueryStub; var oldLegacyFileActions; @@ -48,6 +49,7 @@ describe('OCA.Files.App tests', function() { OCA.Files.fileActions = new OCA.Files.FileActions(); pushStateStub = sinon.stub(OC.Util.History, 'pushState'); + replaceStateStub = sinon.stub(OC.Util.History, 'replaceState'); parseUrlQueryStub = sinon.stub(OC.Util.History, 'parseUrlQuery'); parseUrlQueryStub.returns({}); @@ -59,6 +61,7 @@ describe('OCA.Files.App tests', function() { window.FileActions = oldLegacyFileActions; pushStateStub.restore(); + replaceStateStub.restore(); parseUrlQueryStub.restore(); }); @@ -132,6 +135,23 @@ describe('OCA.Files.App tests', function() { expect(pushStateStub.getCall(0).args[0].dir).toEqual('subdir'); expect(pushStateStub.getCall(0).args[0].view).toEqual('other'); }); + it('replaces the state to the URL when fileid is known', function() { + $('#app-content-files').trigger(new $.Event('changeDirectory', {dir: 'subdir'})); + expect(pushStateStub.calledOnce).toEqual(true); + expect(pushStateStub.getCall(0).args[0].dir).toEqual('subdir'); + expect(pushStateStub.getCall(0).args[0].view).not.toBeDefined(); + expect(replaceStateStub.notCalled).toEqual(true); + + parseUrlQueryStub.returns({dir: 'subdir'}); + + $('#app-content-files').trigger(new $.Event('afterChangeDirectory', {dir: 'subdir', fileId: 123})); + + expect(pushStateStub.calledOnce).toEqual(true); + expect(replaceStateStub.calledOnce).toEqual(true); + expect(replaceStateStub.getCall(0).args[0].dir).toEqual('subdir'); + expect(replaceStateStub.getCall(0).args[0].view).not.toBeDefined(); + expect(replaceStateStub.getCall(0).args[0].fileid).toEqual(123); + }); describe('onpopstate', function() { it('sends "urlChanged" event to current app', function() { var handler = sinon.stub(); diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js index cc3bcd74b46..7e6408128bb 100644 --- a/apps/files/tests/js/filelistSpec.js +++ b/apps/files/tests/js/filelistSpec.js @@ -1358,6 +1358,15 @@ describe('OCA.Files.FileList tests', function() { expect(handler.calledOnce).toEqual(true); expect(handler.getCall(0).args[0].dir).toEqual('/somedir'); }); + it('triggers "afterChangeDirectory" event with fileid after changing directory', function() { + var handler = sinon.stub(); + $('#app-content-files').on('afterChangeDirectory', handler); + fileList.changeDirectory('/somedir'); + deferredList.resolve(200, [testRoot].concat(testFiles)); + expect(handler.calledOnce).toEqual(true); + expect(handler.getCall(0).args[0].dir).toEqual('/somedir'); + expect(handler.getCall(0).args[0].fileId).toEqual(99); + }); it('changes the directory when receiving "urlChanged" event', function() { $('#app-content-files').trigger(new $.Event('urlChanged', {view: 'files', dir: '/somedir'})); expect(fileList.getCurrentDirectory()).toEqual('/somedir'); |