summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-10-22 09:23:05 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2015-10-22 09:23:05 +0200
commit15ef39d5b9655c6c10ea58ffa94b7a80efc6290d (patch)
tree1f11bdcc94f784f9a5ab8f70f16db7bae428d3ce
parent06fdd94060ab70c1502d350931c685ea5524f6e8 (diff)
parente3ae453ee5af1f6e3cce3523ded727ba9a0cfcbc (diff)
downloadnextcloud-server-15ef39d5b9655c6c10ea58ffa94b7a80efc6290d.tar.gz
nextcloud-server-15ef39d5b9655c6c10ea58ffa94b7a80efc6290d.zip
Merge pull request #19952 from owncloud/share-dialogue-tests
Add JS tests for share dialog
-rw-r--r--core/js/tests/specs/sharedialogviewSpec.js78
1 files changed, 78 insertions, 0 deletions
diff --git a/core/js/tests/specs/sharedialogviewSpec.js b/core/js/tests/specs/sharedialogviewSpec.js
index 55aa0541bd0..0117f517d4c 100644
--- a/core/js/tests/specs/sharedialogviewSpec.js
+++ b/core/js/tests/specs/sharedialogviewSpec.js
@@ -676,5 +676,83 @@ describe('OC.Share.ShareDialogView', function() {
});
});
});
+ describe('remote sharing', function() {
+ it('shows remote share info when allows', function() {
+ configModel.set({
+ isRemoteShareAllowed: true
+ });
+ dialog.render();
+ expect(dialog.$el.find('.shareWithRemoteInfo').length).toEqual(1);
+ });
+ it('does not show remote share info when not allowed', function() {
+ configModel.set({
+ isRemoteShareAllowed: false
+ });
+ dialog.render();
+ expect(dialog.$el.find('.shareWithRemoteInfo').length).toEqual(0);
+ });
+ });
+ describe('autocompeltion of users', function() {
+ it('triggers autocomplete display and focus with data when ajax search succeeds', function () {
+ dialog.render();
+ var response = sinon.stub();
+ dialog.autocompleteHandler({term: 'bob'}, response);
+ var jsonData = JSON.stringify({
+ "data": [{"label": "bob", "value": {"shareType": 0, "shareWith": "test"}}],
+ "status": "success"
+ });
+ fakeServer.requests[0].respond(
+ 200,
+ {'Content-Type': 'application/json'},
+ jsonData
+ );
+ expect(response.calledWithExactly(JSON.parse(jsonData).data)).toEqual(true);
+ expect(autocompleteStub.calledWith("option", "autoFocus", true)).toEqual(true);
+ });
+
+ it('gracefully handles successful ajax call with failure content', function () {
+ dialog.render();
+ var response = sinon.stub();
+ dialog.autocompleteHandler({term: 'bob'}, response);
+ var jsonData = JSON.stringify({"status": "failure"});
+ fakeServer.requests[0].respond(
+ 200,
+ {'Content-Type': 'application/json'},
+ jsonData
+ );
+ expect(response.calledWithExactly()).toEqual(true);
+ });
+
+ it('throws a notification when the ajax search lookup fails', function () {
+ notificationStub = sinon.stub(OC.Notification, 'show');
+ dialog.render();
+ dialog.autocompleteHandler({term: 'bob'}, sinon.stub());
+ fakeServer.requests[0].respond(500);
+ expect(notificationStub.calledOnce).toEqual(true);
+ notificationStub.restore();
+ });
+
+ describe('renders the autocomplete elements', function() {
+ it('renders a group element', function() {
+ dialog.render();
+ var el = dialog.autocompleteRenderItem(
+ $("<ul></ul>"),
+ {label: "1", value: { shareType: OC.Share.SHARE_TYPE_GROUP }}
+ );
+ expect(el.is('li')).toEqual(true);
+ expect(el.hasClass('group')).toEqual(true);
+ });
+
+ it('renders a remote element', function() {
+ dialog.render();
+ var el = dialog.autocompleteRenderItem(
+ $("<ul></ul>"),
+ {label: "1", value: { shareType: OC.Share.SHARE_TYPE_REMOTE }}
+ );
+ expect(el.is('li')).toEqual(true);
+ expect(el.hasClass('user')).toEqual(true);
+ });
+ });
+ });
});