Browse Source

Fix failing tests after introducing AMD version of Strophe

JC Brand 10 năm trước cách đây
mục cha
commit
f283f6bce5
11 tập tin đã thay đổi với 30 bổ sung53 xóa
  1. 7 1
      converse.js
  2. 3 0
      spec/chatbox.js
  3. 3 0
      spec/chatroom.js
  4. 2 0
      spec/controlbox.js
  5. 2 1
      spec/converse.js
  6. 2 0
      spec/minchats.js
  7. 2 0
      spec/otr.js
  8. 2 0
      spec/profiling.js
  9. 2 0
      spec/register.js
  10. 4 51
      tests/mock.js
  11. 1 0
      tests/utils.js

+ 7 - 1
converse.js

@@ -23,6 +23,7 @@
     var $iq =       dependencies.$iq;
     var $msg =      dependencies.$msg;
     var $pres =     dependencies.$pres;
+    var $build =    dependencies.$build;
     var DSA =       dependencies.otr ? dependencies.otr.DSA : undefined;
     var OTR =       dependencies.otr ? dependencies.otr.OTR : undefined;
     var Strophe =   dependencies.Strophe;
@@ -5280,7 +5281,12 @@
         'env': {
             'jQuery': $,
             'Strophe': Strophe, // TODO: this must be wrapped
-            '_': _
+            '$build': $build,
+            '$iq': $iq,
+            '$pres': $pres,
+            '$msg': $msg,
+            '_': _,
+            'b64_sha1':  b64_sha1
         },
 
         // Deprecated API methods

+ 3 - 0
spec/chatbox.js

@@ -8,6 +8,9 @@
         }
     );
 } (this, function ($, mock, test_utils) {
+    var $msg = converse_api.env.$msg;
+    var Strophe = converse_api.env.Strophe;
+
     return describe("Chatboxes", $.proxy(function(mock, test_utils) {
         describe("A Chatbox", $.proxy(function () {
             beforeEach(function () {

+ 3 - 0
spec/chatroom.js

@@ -8,6 +8,9 @@
         }
     );
 } (this, function ($, mock, test_utils) {
+    var $pres = converse_api.env.$pres;
+    var $msg = converse_api.env.$msg;
+
     return describe("ChatRooms", $.proxy(function (mock, test_utils) {
         describe("A Chat Room", $.proxy(function () {
             beforeEach(function () {

+ 2 - 0
spec/controlbox.js

@@ -8,6 +8,8 @@
         }
     );
 } (this, function ($, mock, test_utils) {
+    var $pres = converse_api.env.$pres;
+    var $iq = converse_api.env.$iq;
 
     var checkHeaderToggling = function ($header) {
         var $toggle = $header.find('a.group-toggle');

+ 2 - 1
spec/converse.js

@@ -8,8 +8,9 @@
         }
     );
 } (this, function ($, mock, test_utils) {
-    return describe("Converse", $.proxy(function(mock, test_utils) {
+    var b64_sha1 = converse_api.env.b64_sha1;
 
+    return describe("Converse", $.proxy(function(mock, test_utils) {
         describe("The \"tokens\" API", $.proxy(function () {
             beforeEach($.proxy(function () {
                 test_utils.closeAllChatBoxes();

+ 2 - 0
spec/minchats.js

@@ -8,6 +8,8 @@
         }
     );
 } (this, function ($, mock, test_utils) {
+    var $msg = converse_api.env.$msg;
+
     return describe("The Minimized Chats Widget", $.proxy(function(mock, test_utils) {
         beforeEach(function () {
             runs(function () {

+ 2 - 0
spec/otr.js

@@ -8,6 +8,8 @@
         }
     );
 } (this, function ($, mock, test_utils) {
+    var b64_sha1 = converse_api.env.b64_sha1;
+
     return describe("The OTR module", $.proxy(function(mock, test_utils) {
 
         beforeEach($.proxy(function () {

+ 2 - 0
spec/profiling.js

@@ -8,6 +8,8 @@
         }
     );
 } (this, function ($, mock, test_utils) {
+    var Strophe = converse_api.env.Strophe;
+
     describe("Profiling", function() {
         beforeEach(function() {
             converse.connection.roster.items = [];

+ 2 - 0
spec/register.js

@@ -8,6 +8,8 @@
         }
     );
 } (this, function ($, mock, test_utils) {
+    var Strophe = converse_api.env.Strophe;
+    var $iq = converse_api.env.$iq;
 
     describe("The Registration Panel", $.proxy(function (mock, test_utils) {
         beforeEach(function () {

+ 4 - 51
tests/mock.js

@@ -1,10 +1,12 @@
 (function (root, factory) {
     define("mock",
         ['converse'],
-        function() {
-            return factory();
+        function(converse) {
+            return factory(converse);
         });
 }(this, function (converse) {
+    var Strophe = converse.env.Strophe;
+    var $iq = converse.env.$iq;
     var mock = {};
     // Names from http://www.fakenamegenerator.com/
     mock.req_names = [
@@ -64,54 +66,5 @@
         c.attach(c.jid);
         return c;
     }();
-
-    /*
-    {
-        'muc': {
-            'listRooms': function () {},
-            'join': function () {},
-            'leave': function () {},
-            'rooms': {},
-            'groupchat': function () {return String((new Date()).getTime()); }
-        },
-        'service': 'jasmine tests',
-        'addHandler': function (handler, ns, name, type, id, from, options) {
-            return function () {};
-        },
-        'send': function () {},
-        'roster': {
-            'add': function () {},
-            'authorize': function () {},
-            'unauthorize': function () {},
-            'get': function () {},
-            'subscribe': function () {},
-            'registerCallback': function () {},
-            'remove': function (jid, callback) { callback(); }
-        },
-        'vcard': {
-            'get': function (callback, jid) {
-                var fullname;
-                if (!jid) {
-                    jid = 'dummy@localhost';
-                    fullname = 'Max Mustermann' ;
-                } else {
-                    var name = jid.split('@')[0].replace(/\./g, ' ').split(' ');
-                    var last = name.length-1;
-                    name[0] =  name[0].charAt(0).toUpperCase()+name[0].slice(1);
-                    name[last] = name[last].charAt(0).toUpperCase()+name[last].slice(1);
-                    fullname = name.join(' ');
-                }
-                var vcard = $iq().c('vCard').c('FN').t(fullname);
-                callback(vcard.tree());
-            }
-        },
-        'disco': {
-            'addFeature': function () {},
-            'addIdentity': function () {},
-            'info': function () {},
-            'items': function () {}
-        }
-    };
-    */
     return mock;
 }));

+ 1 - 0
tests/utils.js

@@ -7,6 +7,7 @@
             return factory($, mock);
         });
 }(this, function ($, mock) {
+    var Strophe = converse_api.env.Strophe;
     var utils = {};
 
     utils.createRequest = function (iq) {