summaryrefslogtreecommitdiffstats
path: root/core/js/tests/specs/shareitemmodelSpec.js
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2017-04-24 21:31:53 +0200
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2017-04-24 21:31:53 +0200
commit6e9f49f3974c0e77c2d556004723b6192b3036a8 (patch)
treef7456d0da5c7843725f2341d3b6fda7bf8459f02 /core/js/tests/specs/shareitemmodelSpec.js
parent488020cf2efaa84f80bf5d39a0065b602b6d0a12 (diff)
downloadnextcloud-server-6e9f49f3974c0e77c2d556004723b6192b3036a8.tar.gz
nextcloud-server-6e9f49f3974c0e77c2d556004723b6192b3036a8.zip
Add "complete" callback support for addShare
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'core/js/tests/specs/shareitemmodelSpec.js')
-rw-r--r--core/js/tests/specs/shareitemmodelSpec.js53
1 files changed, 53 insertions, 0 deletions
diff --git a/core/js/tests/specs/shareitemmodelSpec.js b/core/js/tests/specs/shareitemmodelSpec.js
index 5c5aa9608b2..771a9263709 100644
--- a/core/js/tests/specs/shareitemmodelSpec.js
+++ b/core/js/tests/specs/shareitemmodelSpec.js
@@ -670,6 +670,30 @@ describe('OC.Share.ShareItemModel', function() {
shareWith: 'group1'
});
});
+ it('calls complete handler before refreshing the model', function() {
+ var completeStub = sinon.stub();
+ model.addShare({
+ shareType: OC.Share.SHARE_TYPE_GROUP,
+ shareWith: 'group1'
+ }, {
+ complete: completeStub
+ });
+
+ expect(fakeServer.requests.length).toEqual(1);
+ fakeServer.requests[0].respond(
+ 200,
+ { 'Content-Type': 'application/json' },
+ JSON.stringify({ })
+ );
+
+ expect(completeStub.calledOnce).toEqual(true);
+ expect(completeStub.lastCall.args[0]).toEqual(model);
+
+ fetchReshareDeferred.resolve(makeOcsResponse([]));
+ fetchSharesDeferred.resolve(makeOcsResponse([]));
+
+ expect(completeStub.calledOnce).toEqual(true);
+ });
it('calls success handler after refreshing the model', function() {
var successStub = sinon.stub();
model.addShare({
@@ -694,6 +718,35 @@ describe('OC.Share.ShareItemModel', function() {
expect(successStub.calledOnce).toEqual(true);
expect(successStub.lastCall.args[0]).toEqual(model);
});
+ it('calls complete handler before error handler', function() {
+ var completeStub = sinon.stub();
+ var errorStub = sinon.stub();
+ model.addShare({
+ shareType: OC.Share.SHARE_TYPE_GROUP,
+ shareWith: 'group1'
+ }, {
+ complete: completeStub,
+ 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(completeStub.calledOnce).toEqual(true);
+ expect(completeStub.lastCall.args[0]).toEqual(model);
+ expect(errorStub.calledOnce).toEqual(true);
+ expect(completeStub.calledBefore(errorStub)).toEqual(true);
+ });
it('calls error handler with error message', function() {
var errorStub = sinon.stub();
model.addShare({