]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix unit tests
authorRoeland Jago Douma <rullzer@owncloud.com>
Wed, 23 Dec 2015 09:49:27 +0000 (10:49 +0100)
committerRoeland Jago Douma <rullzer@owncloud.com>
Wed, 30 Dec 2015 07:58:04 +0000 (08:58 +0100)
core/js/sharedialogview.js
core/js/tests/specs/sharedialogviewSpec.js

index c89c1d95be965c1fc9aee77b525d1bfc4d2e833b..4cebf7962e8b081c0d10d625e1ee69e8cb038afa 100644 (file)
                                        $loading.addClass('hidden');
                                        $loading.removeClass('inlineblock');
                                        if (result.ocs.meta.statuscode == 100) {
-                                               var users   = [].concat(result.ocs.data.exact.users).concat(result.ocs.data.users);
+                                               var users   = result.ocs.data.exact.users.concat(result.ocs.data.users);
                                                var groups  = result.ocs.data.exact.groups.concat(result.ocs.data.groups);
                                                var remotes = result.ocs.data.exact.remotes.concat(result.ocs.data.remotes);
 
 
                                                var suggestions = users.concat(groups).concat(remotes);
 
-                                               $('.shareWithField').autocomplete("option", "autoFocus", true);
-                                               response(suggestions);
+                                               if (suggestions.length > 0) {
+                                                       $('.shareWithField').autocomplete("option", "autoFocus", true);
+                                                       response(suggestions);
+                                               } else {
+                                                       response();
+                                               }
                                        } else {
                                                response();
                                        }
index bfd3d98786602094f20c0e3435e4d30256d2a7d5..2a2be72c21811e5cb25c9b96e7c223c3b6238b11 100644 (file)
@@ -724,15 +724,30 @@ describe('OC.Share.ShareDialogView', function() {
                        var response = sinon.stub();
                        dialog.autocompleteHandler({term: 'bob'}, response);
                        var jsonData = JSON.stringify({
-                               "data": [{"label": "bob", "value": {"shareType": 0, "shareWith": "test"}}],
-                               "status": "success"
+                               'ocs' : {
+                                       'meta' : {
+                                               'status' : 'success',
+                                               'statuscode' : 100,
+                                               'message' : null
+                                       },
+                                       'data' : {
+                                               'exact' : {
+                                                       'users'  : [],
+                                                       'groups' : [],
+                                                       'remotes': []
+                                               },
+                                               'users'  : [{'label': 'bob', 'value': {'shareType': 0, 'shareWith': 'test'}}],
+                                               'groups' : [],
+                                               'remotes': []
+                                       }
+                               }
                        });
                        fakeServer.requests[0].respond(
                                        200,
                                        {'Content-Type': 'application/json'},
                                        jsonData
                        );
-                       expect(response.calledWithExactly(JSON.parse(jsonData).data)).toEqual(true);
+                       expect(response.calledWithExactly(JSON.parse(jsonData).ocs.data.users)).toEqual(true);
                        expect(autocompleteStub.calledWith("option", "autoFocus", true)).toEqual(true);
                });
 
@@ -740,7 +755,14 @@ describe('OC.Share.ShareDialogView', function() {
                        dialog.render();
                        var response = sinon.stub();
                        dialog.autocompleteHandler({term: 'bob'}, response);
-                       var jsonData = JSON.stringify({"status": "failure"});
+                       var jsonData = JSON.stringify({
+                               'ocs' : {
+                                       'meta' : {
+                                               'status': 'failure',
+                                               'statuscode': 400
+                                       }
+                               }
+                       });
                        fakeServer.requests[0].respond(
                                        200,
                                        {'Content-Type': 'application/json'},