From 375eab9df3997480ae56eea233e6eec2c3fdf82c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Fri, 16 Mar 2018 17:19:22 +0100 Subject: [PATCH] Add tests for emails and circles already shared with MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Calviño Sánchez --- core/js/tests/specs/sharedialogviewSpec.js | 121 ++++++++++++++++++++- 1 file changed, 120 insertions(+), 1 deletion(-) diff --git a/core/js/tests/specs/sharedialogviewSpec.js b/core/js/tests/specs/sharedialogviewSpec.js index c014dfc15d..684c2bea45 100644 --- a/core/js/tests/specs/sharedialogviewSpec.js +++ b/core/js/tests/specs/sharedialogviewSpec.js @@ -642,7 +642,20 @@ describe('OC.Share.ShareDialogView', function() { share_type: OC.Share.SHARE_TYPE_REMOTE, share_with: 'foo@bar.com/baz', share_with_displayname: 'foo@bar.com/baz' - + },{ + id: 103, + item_source: 123, + permissions: 31, + share_type: OC.Share.SHARE_TYPE_EMAIL, + share_with: 'foo@bar.com', + share_with_displayname: 'foo@bar.com' + },{ + id: 104, + item_source: 123, + permissions: 31, + share_type: OC.Share.SHARE_TYPE_CIRCLE, + share_with: 'shortId', + share_with_displayname: 'CircleName (type, owner)' }] }); }); @@ -799,6 +812,112 @@ describe('OC.Share.ShareDialogView', function() { }])).toEqual(true); expect(autocompleteStub.calledWith("option", "autoFocus", true)).toEqual(true); }); + + it('emails', function () { + dialog.render(); + var response = sinon.stub(); + dialog.autocompleteHandler({term: 'foo'}, response); + var jsonData = JSON.stringify({ + 'ocs': { + 'meta': { + 'status': 'success', + 'statuscode': 100, + 'message': null + }, + 'data': { + 'exact': { + 'users': [], + 'groups': [], + 'remotes': [], + 'emails': [] + }, + 'users': [], + 'groups': [], + 'remotes': [], + 'lookup': [], + 'emails': [ + { + 'label': 'foo@bar.com', + 'value': { + 'shareType': OC.Share.SHARE_TYPE_EMAIL, + 'shareWith': 'foo@bar.com' + } + }, + { + 'label': 'foo2@bar.com', + 'value': { + 'shareType': OC.Share.SHARE_TYPE_EMAIL, + 'shareWith': 'foo2@bar.com' + } + } + ] + } + } + }); + fakeServer.requests[0].respond( + 200, + {'Content-Type': 'application/json'}, + jsonData + ); + expect(response.calledWithExactly([{ + 'label': 'foo2@bar.com', + 'value': {'shareType': OC.Share.SHARE_TYPE_EMAIL, 'shareWith': 'foo2@bar.com'} + }])).toEqual(true); + expect(autocompleteStub.calledWith("option", "autoFocus", true)).toEqual(true); + }); + + it('circles', function () { + dialog.render(); + var response = sinon.stub(); + dialog.autocompleteHandler({term: 'CircleNam'}, response); + var jsonData = JSON.stringify({ + 'ocs': { + 'meta': { + 'status': 'success', + 'statuscode': 100, + 'message': null + }, + 'data': { + 'exact': { + 'users': [], + 'groups': [], + 'remotes': [], + 'circles': [] + }, + 'users': [], + 'groups': [], + 'remotes': [], + 'lookup': [], + 'circles': [ + { + 'label': 'CircleName (type, owner)', + 'value': { + 'shareType': OC.Share.SHARE_TYPE_CIRCLE, + 'shareWith': 'shortId' + } + }, + { + 'label': 'CircleName (type2, owner)', + 'value': { + 'shareType': OC.Share.SHARE_TYPE_CIRCLE, + 'shareWith': 'shortId2' + } + } + ] + } + } + }); + fakeServer.requests[0].respond( + 200, + {'Content-Type': 'application/json'}, + jsonData + ); + expect(response.calledWithExactly([{ + 'label': 'CircleName (type2, owner)', + 'value': {'shareType': OC.Share.SHARE_TYPE_CIRCLE, 'shareWith': 'shortId2'} + }])).toEqual(true); + expect(autocompleteStub.calledWith("option", "autoFocus", true)).toEqual(true); + }); }); });