Browse Source

No need for two AMD-load cycles.

JC Brand 8 years ago
parent
commit
de07b6a529

+ 1 - 1
package.json

@@ -48,7 +48,7 @@
     "jquery": "2.2.3",
     "jquery-easing": "0.0.1",
     "jquery.browser": ">=0.1.0",
-    "jshint": "^2.8.0",
+    "jshint": "^2.9.4",
     "moment": "~2.13.0",
     "otr": "0.2.16",
     "phantom-jasmine": "0.1.8",

+ 2 - 1
spec/bookmarks.js

@@ -1,12 +1,13 @@
 (function (root, factory) {
     define([
         "jquery",
+        "converse-api",
         "underscore",
         "utils",
         "mock",
         "test_utils"
         ], factory);
-} (this, function ($, _, utils, mock, test_utils) {
+} (this, function ($, converse_api, _, utils, mock, test_utils) {
     "use strict";
     var $iq = converse_api.env.$iq,
         Strophe = converse_api.env.Strophe;

+ 2 - 1
spec/chatbox.js

@@ -1,10 +1,11 @@
 (function (root, factory) {
     define([
         "utils",
+        "converse-api",
         "mock",
         "test_utils"
         ], factory);
-} (this, function (utils, mock, test_utils) {
+} (this, function (utils, converse_api, mock, test_utils) {
     "use strict";
     var _ = converse_api.env._;
     var $ = converse_api.env.jQuery;

+ 2 - 2
spec/chatroom.js

@@ -1,6 +1,6 @@
 (function (root, factory) {
-    define(["mock", "test_utils", "utils" ], factory);
-} (this, function (mock, test_utils, utils) {
+    define(["mock", "converse-api", "test_utils", "utils" ], factory);
+} (this, function (mock, converse_api, test_utils, utils) {
     var _ = converse_api.env._;
     var $ = converse_api.env.jQuery;
     var $pres = converse_api.env.$pres;

+ 2 - 2
spec/controlbox.js

@@ -1,6 +1,6 @@
 (function (root, factory) {
-    define(["mock", "test_utils"], factory);
-} (this, function (mock, test_utils) {
+    define(["mock", "converse-api", "test_utils"], factory);
+} (this, function (mock, converse_api, test_utils) {
     var _ = converse_api.env._;
     var $ = converse_api.env.jQuery;
     var $pres = converse_api.env.$pres;

+ 3 - 6
spec/converse.js

@@ -1,14 +1,11 @@
 (function (root, factory) {
     define([
         "jquery",
+        "converse-api",
         "underscore",
         "mock",
-        "test_utils"
-        ], function ($, _, mock, test_utils) {
-            return factory($, _, mock, test_utils);
-        }
-    );
-} (this, function ($, _, mock, test_utils) {
+        "test_utils"], factory);
+} (this, function ($, converse_api, _, mock, test_utils) {
     var b64_sha1 = converse_api.env.b64_sha1;
 
     describe("Converse", function() {

+ 3 - 6
spec/disco.js

@@ -1,13 +1,10 @@
 (function (root, factory) {
     define([
         "jquery",
+        "converse-api",
         "mock",
-        "test_utils"
-        ], function ($, mock, test_utils) {
-            return factory($, mock, test_utils);
-        }
-    );
-} (this, function ($, mock, test_utils) {
+        "test_utils"], factory);
+} (this, function ($, converse_api, mock, test_utils) {
     "use strict";
     var Strophe = converse_api.env.Strophe;
 

+ 2 - 2
spec/eventemitter.js

@@ -1,6 +1,6 @@
 (function (root, factory) {
-    define(["mock", "test_utils"], factory);
-} (this, function (mock, test_utils) {
+    define(["mock", "converse-api", "test_utils"], factory);
+} (this, function (mock, converse_api, test_utils) {
 
     return describe("The Converse Event Emitter", function() {
 

+ 2 - 1
spec/headline.js

@@ -1,11 +1,12 @@
 (function (root, factory) {
     define([
         "jquery",
+        "converse-api",
         "utils",
         "mock",
         "test_utils"
         ], factory);
-} (this, function ($, utils, mock, test_utils) {
+} (this, function ($, converse_api, utils, mock, test_utils) {
     "use strict";
     var $msg = converse_api.env.$msg,
         _ = converse_api.env._;

+ 2 - 2
spec/mam.js

@@ -1,6 +1,6 @@
 (function (root, factory) {
-    define(["mock", "test_utils"], factory);
-} (this, function (mock, test_utils) {
+    define(["mock", "converse-api", "test_utils"], factory);
+} (this, function (mock, converse_api, test_utils) {
     "use strict";
     var _ = converse_api.env._;
     var $ = converse_api.env.jQuery;

+ 2 - 2
spec/minchats.js

@@ -1,6 +1,6 @@
 (function (root, factory) {
-    define(["mock", "test_utils"], factory);
-} (this, function (mock, test_utils) {
+    define(["mock", "converse-api", "test_utils"], factory);
+} (this, function (mock, converse_api, test_utils) {
     var _ = converse_api.env._;
     var $msg = converse_api.env.$msg;
 

+ 2 - 2
spec/notification.js

@@ -1,6 +1,6 @@
 (function (root, factory) {
-    define(["mock", "test_utils"], factory);
-} (this, function (mock, test_utils) {
+    define(["mock", "converse-api", "test_utils"], factory);
+} (this, function (mock, converse_api, test_utils) {
     "use strict";
     var $msg = converse_api.env.$msg;
 

+ 2 - 2
spec/otr.js

@@ -1,6 +1,6 @@
 (function (root, factory) {
-    define(["mock","test_utils" ], factory);
-} (this, function (mock, test_utils) {
+    define(["mock", "converse-api", "test_utils"], factory);
+} (this, function (mock, converse_api, test_utils) {
     var $ = converse_api.env.jQuery;
     var Strophe = converse_api.env.Strophe;
     var b64_sha1 = converse_api.env.b64_sha1;

+ 2 - 2
spec/ping.js

@@ -1,6 +1,6 @@
 (function (root, factory) {
-    define(["mock", "test_utils", "converse-ping"], factory);
-} (this, function (mock, test_utils) {
+    define(["mock", "converse-api", "test_utils", "converse-ping"], factory);
+} (this, function (mock, converse_api, test_utils) {
     "use strict";
 
     describe("XMPP Ping", function () {

+ 2 - 2
spec/profiling.js

@@ -1,6 +1,6 @@
 (function (root, factory) {
-    define(["mock", "test_utils"], factory);
-} (this, function (mock, test_utils) {
+    define(["mock", "converse-api", "test_utils"], factory);
+} (this, function (mock, converse_api, test_utils) {
     var _ = converse_api.env._;
     var $iq = converse_api.env.$iq;
 

+ 3 - 6
spec/protocol.js

@@ -1,13 +1,10 @@
 (function (root, factory) {
     define([
         "jquery",
+        "converse-api",
         "mock",
-        "test_utils"
-        ], function ($, mock, test_utils) {
-            return factory($, mock, test_utils);
-        }
-    );
-} (this, function ($, mock, test_utils) {
+        "test_utils"], factory);
+} (this, function ($, converse_api, mock, test_utils) {
     "use strict";
     var Strophe = converse_api.env.Strophe;
     var $iq = converse_api.env.$iq;

+ 2 - 2
spec/register.js

@@ -1,6 +1,6 @@
 (function (root, factory) {
-    define(["mock", "test_utils"], factory);
-} (this, function (mock, test_utils) {
+    define(["mock", "converse-api", "test_utils"], factory);
+} (this, function (mock, converse_api, test_utils) {
     var $ = converse_api.env.jQuery;
     var Strophe = converse_api.env.Strophe;
     var $iq = converse_api.env.$iq;

+ 2 - 2
spec/xmppstatus.js

@@ -1,6 +1,6 @@
 (function (root, factory) {
-    define(["mock", "test_utils"], factory);
-} (this, function (mock, test_utils) {
+    define(["mock", "converse-api", "test_utils"], factory);
+} (this, function (mock, converse_api, test_utils) {
     var $ = converse_api.env.jQuery;
 
     return describe("The XMPPStatus model", function() {

+ 42 - 46
tests/main.js

@@ -10,6 +10,9 @@ config.shim['jasmine-html'] = {
     deps: ['jasmine'],
     exports: 'jasmine'
 };
+config.shim['console-runner'] = {
+    deps: ['jasmine']
+};
 require.config(config);
 
 // Polyfill 'bind' which is not available in phantomjs < 2.0
@@ -34,56 +37,49 @@ if (!Function.prototype.bind) {
 
 require([
     "jquery",
-    "converse",
     "mock",
     "jasmine-html",
-    "sinon"
-    ], function($, converse, mock, jasmine, sinon) {
-        // Set up converse.js
+    "sinon",
+    "console-runner",
+    //"spec/transcripts",
+    "spec/utils",
+    "spec/converse",
+    "spec/bookmarks",
+    "spec/headline",
+    "spec/disco",
+    "spec/protocol",
+    "spec/mam",
+    "spec/otr",
+    "spec/eventemitter",
+    "spec/controlbox",
+    "spec/chatbox",
+    "spec/chatroom",
+    "spec/minchats",
+    "spec/notification",
+    "spec/profiling",
+    "spec/ping",
+    "spec/register",
+    "spec/xmppstatus"
+    ], function($, mock, jasmine, sinon) {
         window.sinon = sinon;
-        window.converse_api = converse;
         window.localStorage.clear();
         window.sessionStorage.clear();
-
-        require([
-            "console-runner",
-            //"spec/transcripts",
-            "spec/utils",
-            "spec/converse",
-            "spec/bookmarks",
-            "spec/headline",
-            "spec/disco",
-            "spec/protocol",
-            "spec/mam",
-            "spec/otr",
-            "spec/eventemitter",
-            "spec/controlbox",
-            "spec/chatbox",
-            "spec/chatroom",
-            "spec/minchats",
-            "spec/notification",
-            "spec/profiling",
-            "spec/ping",
-            "spec/register",
-            "spec/xmppstatus"
-        ], function () {
-            // Jasmine stuff
-            var jasmineEnv = jasmine.getEnv();
-            var reporter;
-            if (/PhantomJS/.test(navigator.userAgent)) {
-                reporter = new jasmine.ConsoleReporter();
-                window.console_reporter = reporter;
-                jasmineEnv.addReporter(reporter);
-                jasmineEnv.updateInterval = 0;
-            } else {
-                reporter = new jasmine.HtmlReporter();
-                jasmineEnv.addReporter(reporter);
-                jasmineEnv.specFilter = function(spec) {
-                    return reporter.specFilter(spec);
-                };
-                jasmineEnv.updateInterval = 0;
-            }
-            jasmineEnv.execute();
-        });
+        // Jasmine stuff
+        var jasmineEnv = jasmine.getEnv();
+        var reporter;
+        if (/PhantomJS/.test(navigator.userAgent)) {
+            reporter = new jasmine.ConsoleReporter();
+            window.console_reporter = reporter;
+            jasmineEnv.addReporter(reporter);
+            jasmineEnv.updateInterval = 0;
+        } else {
+            reporter = new jasmine.HtmlReporter();
+            jasmineEnv.addReporter(reporter);
+            jasmineEnv.specFilter = function(spec) {
+                return reporter.specFilter(spec);
+            };
+            jasmineEnv.updateInterval = 0;
+        }
+        jasmineEnv.execute();
     }
 );