diff options
author | Vincent Petry <pvince81@owncloud.com> | 2016-01-28 17:07:51 +0100 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2016-01-28 17:18:33 +0100 |
commit | df3f6fee10f70d7a083fb51a03fd8f797ca51b21 (patch) | |
tree | c568c9282858f80ac0c7f153ab00b248d9dd8299 /core/js/tests/specs/shareitemmodelSpec.js | |
parent | 8b3d7d09d52ba169953d6a7d03ab570eb3ceed7a (diff) | |
download | nextcloud-server-df3f6fee10f70d7a083fb51a03fd8f797ca51b21.tar.gz nextcloud-server-df3f6fee10f70d7a083fb51a03fd8f797ca51b21.zip |
Properly forward error messages in share dialog
Diffstat (limited to 'core/js/tests/specs/shareitemmodelSpec.js')
-rw-r--r-- | core/js/tests/specs/shareitemmodelSpec.js | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/core/js/tests/specs/shareitemmodelSpec.js b/core/js/tests/specs/shareitemmodelSpec.js index e1a14bbbe7f..b2480a8beaa 100644 --- a/core/js/tests/specs/shareitemmodelSpec.js +++ b/core/js/tests/specs/shareitemmodelSpec.js @@ -659,6 +659,47 @@ describe('OC.Share.ShareItemModel', function() { password: 'test' }); }); + it('forwards error message on add', function() { + var errorStub = sinon.stub(); + model.set({ + linkShare: { + isLinkShare: false + } + }, { + }); + + model.saveLinkShare({ + password: 'test' + }, { + error: errorStub + }); + + addShareStub.yieldTo('error', 'Some error message'); + + expect(errorStub.calledOnce).toEqual(true); + expect(errorStub.lastCall.args[0]).toEqual('Some error message'); + }); + it('forwards error message on update', function() { + var errorStub = sinon.stub(); + model.set({ + linkShare: { + isLinkShare: true, + id: '123' + } + }, { + }); + + model.saveLinkShare({ + password: 'test' + }, { + error: errorStub + }); + + updateShareStub.yieldTo('error', 'Some error message'); + + expect(errorStub.calledOnce).toEqual(true); + expect(errorStub.lastCall.args[0]).toEqual('Some error message'); + }); }); describe('creating shares', function() { it('sends POST method to endpoint with passed values', function() { @@ -680,6 +721,31 @@ describe('OC.Share.ShareItemModel', function() { shareWith: 'group1' }); }); + it('calls error handler with error message', function() { + var errorStub = sinon.stub(); + model.addShare({ + shareType: OC.Share.SHARE_TYPE_GROUP, + shareWith: 'group1' + }, { + error: errorStub + }); + + expect(fakeServer.requests.length).toEqual(1); + fakeServer.requests[0].respond( + 400, + { 'Content-Type': 'application/json' }, + JSON.stringify({ + ocs: { + meta: { + message: 'Some error message' + } + } + }) + ); + + expect(errorStub.calledOnce).toEqual(true); + expect(errorStub.lastCall.args[1]).toEqual('Some error message'); + }); }); describe('updating shares', function() { it('sends PUT method to endpoint with passed values', function() { @@ -697,6 +763,30 @@ describe('OC.Share.ShareItemModel', function() { permissions: '' + (OC.PERMISSION_READ | OC.PERMISSION_SHARE) }); }); + it('calls error handler with error message', function() { + var errorStub = sinon.stub(); + model.updateShare(123, { + permissions: OC.PERMISSION_READ | OC.PERMISSION_SHARE + }, { + error: errorStub + }); + + expect(fakeServer.requests.length).toEqual(1); + fakeServer.requests[0].respond( + 400, + { 'Content-Type': 'application/json' }, + JSON.stringify({ + ocs: { + meta: { + message: 'Some error message' + } + } + }) + ); + + expect(errorStub.calledOnce).toEqual(true); + expect(errorStub.lastCall.args[1]).toEqual('Some error message'); + }); }); describe('removing shares', function() { it('sends DELETE method to endpoint with share id', function() { @@ -709,6 +799,28 @@ describe('OC.Share.ShareItemModel', function() { 'shares/123?format=json' ); }); + it('calls error handler with error message', function() { + var errorStub = sinon.stub(); + model.removeShare(123, { + error: errorStub + }); + + expect(fakeServer.requests.length).toEqual(1); + fakeServer.requests[0].respond( + 400, + { 'Content-Type': 'application/json' }, + JSON.stringify({ + ocs: { + meta: { + message: 'Some error message' + } + } + }) + ); + + expect(errorStub.calledOnce).toEqual(true); + expect(errorStub.lastCall.args[1]).toEqual('Some error message'); + }); }); }); |