summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2017-04-24 21:16:28 +0200
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2017-04-24 21:24:05 +0200
commit726c6c73f4f89ba280a3232f60b7ace121c0056b (patch)
treef4f13db91bb610f91beae325556aac5724c4c6f1 /core
parentfaea890b874857f2ff144c7eb26dec58a3661005 (diff)
downloadnextcloud-server-726c6c73f4f89ba280a3232f60b7ace121c0056b.tar.gz
nextcloud-server-726c6c73f4f89ba280a3232f60b7ace121c0056b.zip
Add missing unit test cases and conditions
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'core')
-rw-r--r--core/js/tests/specs/shareitemmodelSpec.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/core/js/tests/specs/shareitemmodelSpec.js b/core/js/tests/specs/shareitemmodelSpec.js
index 3d3baf75d15..9305b56b711 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 success handler after refreshing the model', function() {
+ var successStub = sinon.stub();
+ model.addShare({
+ shareType: OC.Share.SHARE_TYPE_GROUP,
+ shareWith: 'group1'
+ }, {
+ success: successStub
+ });
+
+ expect(fakeServer.requests.length).toEqual(1);
+ fakeServer.requests[0].respond(
+ 200,
+ { 'Content-Type': 'application/json' },
+ JSON.stringify({ })
+ );
+
+ expect(successStub.called).toEqual(false);
+
+ fetchReshareDeferred.resolve(makeOcsResponse([]));
+ fetchSharesDeferred.resolve(makeOcsResponse([]));
+
+ expect(successStub.calledOnce).toEqual(true);
+ expect(successStub.lastCall.args[0]).toEqual(model);
+ });
it('calls error handler with error message', function() {
var errorStub = sinon.stub();
model.addShare({
@@ -693,6 +717,7 @@ describe('OC.Share.ShareItemModel', function() {
);
expect(errorStub.calledOnce).toEqual(true);
+ expect(errorStub.lastCall.args[0]).toEqual(model);
expect(errorStub.lastCall.args[1]).toEqual('Some error message');
});
});
@@ -712,6 +737,29 @@ describe('OC.Share.ShareItemModel', function() {
permissions: '' + (OC.PERMISSION_READ | OC.PERMISSION_SHARE)
});
});
+ it('calls success handler after refreshing the model', function() {
+ var successStub = sinon.stub();
+ model.updateShare(123, {
+ permissions: OC.PERMISSION_READ | OC.PERMISSION_SHARE
+ }, {
+ success: successStub
+ });
+
+ expect(fakeServer.requests.length).toEqual(1);
+ fakeServer.requests[0].respond(
+ 200,
+ { 'Content-Type': 'application/json' },
+ JSON.stringify({ })
+ );
+
+ expect(successStub.called).toEqual(false);
+
+ fetchReshareDeferred.resolve(makeOcsResponse([]));
+ fetchSharesDeferred.resolve(makeOcsResponse([]));
+
+ expect(successStub.calledOnce).toEqual(true);
+ expect(successStub.lastCall.args[0]).toEqual(model);
+ });
it('calls error handler with error message', function() {
var errorStub = sinon.stub();
model.updateShare(123, {
@@ -734,6 +782,7 @@ describe('OC.Share.ShareItemModel', function() {
);
expect(errorStub.calledOnce).toEqual(true);
+ expect(errorStub.lastCall.args[0]).toEqual(model);
expect(errorStub.lastCall.args[1]).toEqual('Some error message');
});
});