Explorar o código

Remove the need for require.js to run tests

JC Brand %!s(int64=5) %!d(string=hai) anos
pai
achega
7e23adf26f

+ 0 - 1
index.html

@@ -13,7 +13,6 @@
     <link rel="shortcut icon" type="image/ico" href="https://cdn.conversejs.org/6.0.0/dist/favicon.ico"/>
     <link type="text/css" rel="stylesheet" media="screen" href="https://cdn.conversejs.org/6.0.0/dist/website.min.css" />
     <noscript><p><img src="//stats.opkode.com/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript>
-    <script type="text/javascript" src="/src/website.js"></script>
     <script type="text/javascript" src="analytics.js"></script>
     <!-- *********************************************************************** -->
 

+ 0 - 6
package-lock.json

@@ -18823,12 +18823,6 @@
 			"integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=",
 			"dev": true
 		},
-		"requirejs": {
-			"version": "2.3.6",
-			"resolved": "https://registry.npmjs.org/requirejs/-/requirejs-2.3.6.tgz",
-			"integrity": "sha512-ipEzlWQe6RK3jkzikgCupiTbTvm4S0/CAU5GlgptkN5SO6F3u0UD0K18wy6ErDqiCyP4J4YYe1HuAShvsxePLg==",
-			"dev": true
-		},
 		"requires-port": {
 			"version": "1.0.0",
 			"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",

+ 0 - 1
package.json

@@ -98,7 +98,6 @@
     "postcss-clean": "^1.1.0",
     "postcss-loader": "^3.0.0",
     "prettierx": "^0.11.2",
-    "requirejs": "2.3.6",
     "run-headless-chromium": "^0.1.1",
     "sass-loader": "^8.0.2",
     "sinon": "^9.0.2",

+ 4 - 9
spec/autocomplete.js

@@ -1,11 +1,6 @@
-(function (root, factory) {
-    define([
-        "jasmine",
-        "mock",
-        "test-utils"
-        ], factory);
-} (this, function (jasmine, mock, test_utils) {
-    "use strict";
+window.addEventListener('converse-loaded', () => {
+    const mock = window.mock;
+    const test_utils = window.test_utils;
     const $pres = converse.env.$pres;
     const $msg = converse.env.$msg;
     const Strophe = converse.env.Strophe;
@@ -219,4 +214,4 @@
             done();
         }));
     });
-}));
+});

+ 4 - 9
spec/bookmarks.js

@@ -1,11 +1,6 @@
-(function (root, factory) {
-    define([
-        "jasmine",
-        "mock",
-        "test-utils"
-        ], factory);
-} (this, function (jasmine, mock, test_utils) {
-    "use strict";
+window.addEventListener('converse-loaded', () => {
+    const mock = window.mock;
+    const test_utils = window.test_utils;
     const $iq = converse.env.$iq,
          $msg = converse.env.$msg,
          Strophe = converse.env.Strophe,
@@ -618,4 +613,4 @@
             done();
         }));
     });
-}));
+});

+ 4 - 9
spec/chatbox.js

@@ -1,11 +1,6 @@
-(function (root, factory) {
-    define([
-        "jasmine",
-        "mock",
-        "test-utils"
-        ], factory);
-} (this, function (jasmine, mock, test_utils) {
-    "use strict";
+window.addEventListener('converse-loaded', () => {
+    const mock = window.mock;
+    const test_utils = window.test_utils;
     const _ = converse.env._;
     const $msg = converse.env.$msg;
     const Strophe = converse.env.Strophe;
@@ -1613,4 +1608,4 @@
             }));
         });
     });
-}));
+});

+ 4 - 4
spec/controlbox.js

@@ -1,6 +1,6 @@
-(function (root, factory) {
-    define(["jasmine", "mock", "test-utils"], factory);
-} (this, function (jasmine, mock, test_utils) {
+window.addEventListener('converse-loaded', () => {
+    const mock = window.mock;
+    const test_utils = window.test_utils;
     const _ = converse.env._,
           $msg = converse.env.$msg,
           u = converse.env.utils,
@@ -386,4 +386,4 @@
             done();
         }));
     });
-}));
+});

+ 4 - 7
spec/converse.js

@@ -1,9 +1,6 @@
-(function (root, factory) {
-    define([
-        "jasmine",
-        "mock",
-        "test-utils"], factory);
-} (this, function (jasmine, mock, test_utils) {
+window.addEventListener('converse-loaded', () => {
+    const mock = window.mock;
+    const test_utils = window.test_utils;
     const _ = converse.env._,
           u = converse.env.utils;
 
@@ -367,4 +364,4 @@
             });
         });
     });
-}));
+});

+ 4 - 8
spec/disco.js

@@ -1,10 +1,6 @@
-(function (root, factory) {
-    define([
-        "jasmine",
-        "mock",
-        "test-utils"], factory);
-} (this, function (jasmine, mock, test_utils) {
-    "use strict";
+window.addEventListener('converse-loaded', () => {
+    const mock = window.mock;
+    const test_utils = window.test_utils;
     const Strophe = converse.env.Strophe;
     const $iq = converse.env.$iq;
     const _ = converse.env._;
@@ -191,4 +187,4 @@
             }));
         });
     });
-}));
+});

+ 4 - 9
spec/emojis.js

@@ -1,11 +1,6 @@
-(function (root, factory) {
-    define([
-        "jasmine",
-        "mock",
-        "test-utils"
-        ], factory);
-} (this, function (jasmine, mock, test_utils) {
-    "use strict";
+window.addEventListener('converse-loaded', () => {
+    const mock = window.mock;
+    const test_utils = window.test_utils;
     const { Promise, $msg, $pres, sizzle } = converse.env;
     const u = converse.env.utils;
 
@@ -240,4 +235,4 @@
             }));
         });
     });
-}));
+});

+ 3 - 4
spec/eventemitter.js

@@ -1,6 +1,5 @@
-(function (root, factory) {
-    define(["jasmine", "mock"], factory);
-} (this, function (jasmine, mock) {
+window.addEventListener('converse-loaded', () => {
+    const mock = window.mock;
 
     return describe("The _converse Event Emitter", function() {
 
@@ -61,4 +60,4 @@
             done();
         }));
     });
-}));
+});

+ 4 - 9
spec/hats.js

@@ -1,11 +1,6 @@
-(function (root, factory) {
-    define([
-        "jasmine",
-        "mock",
-        "test-utils"
-        ], factory);
-} (this, function (jasmine, mock, test_utils) {
-    "use strict";
+window.addEventListener('converse-loaded', () => {
+    const mock = window.mock;
+    const test_utils = window.test_utils;
     const u = converse.env.utils;
 
     describe("A XEP-0317 MUC Hat", function () {
@@ -82,4 +77,4 @@
             done();
         }));
     })
-}));
+});

+ 4 - 9
spec/headline.js

@@ -1,11 +1,6 @@
-(function (root, factory) {
-    define([
-        "jasmine",
-        "mock",
-        "test-utils"
-        ], factory);
-} (this, function (jasmine, mock, test_utils) {
-    "use strict";
+window.addEventListener('converse-loaded', () => {
+    const mock = window.mock;
+    const test_utils = window.test_utils;
     const $msg = converse.env.$msg,
           _ = converse.env._,
           u = converse.env.utils;
@@ -179,4 +174,4 @@
             done();
         }));
     });
-}));
+});

+ 4 - 8
spec/http-file-upload.js

@@ -1,10 +1,6 @@
-(function (root, factory) {
-    define([
-        "jasmine",
-        "mock",
-        "test-utils"], factory);
-} (this, function (jasmine, mock, test_utils) {
-    "use strict";
+window.addEventListener('converse-loaded', () => {
+    const mock = window.mock;
+    const test_utils = window.test_utils;
     const Strophe = converse.env.Strophe;
     const $iq = converse.env.$iq;
     const _ = converse.env._;
@@ -629,4 +625,4 @@
             });
         });
     });
-}));
+});

+ 4 - 5
spec/login.js

@@ -1,7 +1,6 @@
-(function (root, factory) {
-    define(["jasmine", "mock", "test-utils"], factory);
-} (this, function (jasmine, mock, test_utils) {
-
+window.addEventListener('converse-loaded', () => {
+    const mock = window.mock;
+    const test_utils = window.test_utils;
     const u = converse.env.utils;
 
     describe("The Login Form", function () {
@@ -77,4 +76,4 @@
             });
         }));
     });
-}));
+});

+ 4 - 5
spec/mam.js

@@ -1,7 +1,6 @@
-(function (root, factory) {
-    define(["jasmine", "mock", "test-utils"], factory);
-} (this, function (jasmine, mock, test_utils) {
-    "use strict";
+window.addEventListener('converse-loaded', () => {
+    const mock = window.mock;
+    const test_utils = window.test_utils;
     const Model = converse.env.Model;
     const Strophe = converse.env.Strophe;
     const $iq = converse.env.$iq;
@@ -1098,4 +1097,4 @@
             }));
         });
     });
-}));
+});

+ 4 - 9
spec/messages.js

@@ -1,11 +1,6 @@
-(function (root, factory) {
-    define([
-        "jasmine",
-        "mock",
-        "test-utils"
-        ], factory);
-} (this, function (jasmine, mock, test_utils) {
-    "use strict";
+window.addEventListener('converse-loaded', () => {
+    const mock = window.mock;
+    const test_utils = window.test_utils;
     const { Promise, Strophe, $msg, dayjs, sizzle, _ } = converse.env;
     const u = converse.env.utils;
 
@@ -2083,4 +2078,4 @@
             done();
         }));
     });
-}));
+});

+ 4 - 4
spec/minchats.js

@@ -1,6 +1,6 @@
-(function (root, factory) {
-    define(["jasmine", "mock", "test-utils"], factory);
-} (this, function (jasmine, mock, test_utils) {
+window.addEventListener('converse-loaded', () => {
+    const mock = window.mock;
+    const test_utils = window.test_utils;
     const _ = converse.env._;
     const  $msg = converse.env.$msg;
     const u = converse.env.utils;
@@ -164,4 +164,4 @@
             done();
         }));
     });
-}));
+});

+ 4 - 4
spec/modtools.js

@@ -1,6 +1,6 @@
-(function (root, factory) {
-    define(["jasmine", "mock", "test-utils" ], factory);
-} (this, function (jasmine, mock, test_utils) {
+window.addEventListener('converse-loaded', () => {
+    const mock = window.mock;
+    const test_utils = window.test_utils;
     const _ = converse.env._;
     const $iq = converse.env.$iq;
     const $pres = converse.env.$pres;
@@ -367,4 +367,4 @@
             done();
         }));
     });
-}));
+});

+ 4 - 4
spec/muc.js

@@ -1,6 +1,6 @@
-(function (root, factory) {
-    define(["jasmine", "mock", "test-utils" ], factory);
-} (this, function (jasmine, mock, test_utils) {
+window.addEventListener('converse-loaded', () => {
+    const mock = window.mock;
+    const test_utils = window.test_utils;
     const _ = converse.env._,
           $pres = converse.env.$pres,
           $iq = converse.env.$iq,
@@ -5311,4 +5311,4 @@
             }));
         });
     });
-}));
+});

+ 4 - 9
spec/muc_messages.js

@@ -1,11 +1,6 @@
-(function (root, factory) {
-    define([
-        "jasmine",
-        "mock",
-        "test-utils"
-        ], factory);
-} (this, function (jasmine, mock, test_utils) {
-    "use strict";
+window.addEventListener('converse-loaded', () => {
+    const mock = window.mock;
+    const test_utils = window.test_utils;
     const { Promise, Strophe, $msg, $pres, sizzle, stanza_utils } = converse.env;
     const u = converse.env.utils;
 
@@ -1254,4 +1249,4 @@
             }));
         });
     });
-}));
+});

+ 4 - 5
spec/notification.js

@@ -1,7 +1,6 @@
-(function (root, factory) {
-    define(["jasmine", "mock", "test-utils"], factory);
-} (this, function (jasmine, mock, test_utils) {
-    "use strict";
+window.addEventListener('converse-loaded', () => {
+    const mock = window.mock;
+    const test_utils = window.test_utils;
     const _ = converse.env._;
     const $msg = converse.env.$msg;
     const u = converse.env.utils;
@@ -207,4 +206,4 @@
             });
         });
     });
-}));
+});

+ 4 - 5
spec/omemo.js

@@ -1,10 +1,9 @@
-(function (root, factory) {
-    define(["jasmine", "mock", "test-utils"], factory);
-} (this, function (jasmine, mock, test_utils) {
+window.addEventListener('converse-loaded', () => {
+    const mock = window.mock;
+    const test_utils = window.test_utils;
     const { $iq, $pres, $msg, _, Strophe } = converse.env;
     const u = converse.env.utils;
 
-
     async function deviceListFetched (_converse, jid) {
         const selector = `iq[to="${jid}"] items[node="eu.siacs.conversations.axolotl.devicelist"]`;
         const stanza = await u.waitUntil(
@@ -1536,4 +1535,4 @@
             done();
         }));
     });
-}));
+});

+ 4 - 5
spec/ping.js

@@ -1,7 +1,6 @@
-(function (root, factory) {
-    define(["jasmine", "mock", "test-utils"], factory);
-} (this, function (jasmine, mock, test_utils) {
-    "use strict";
+window.addEventListener('converse-loaded', () => {
+    const mock = window.mock;
+    const test_utils = window.test_utils;
     const Strophe = converse.env.Strophe;
     const u = converse.env.utils;
 
@@ -34,4 +33,4 @@
             }));
         });
     });
-}));
+});

+ 4 - 12
spec/presence.js

@@ -1,13 +1,6 @@
-/*jshint sub:true*/
-/*eslint dot-notation: "off"*/
-(function (root, factory) {
-    define([
-        "jasmine",
-        "mock",
-        "test-utils",
-    ], factory);
-} (this, function (jasmine, mock, test_utils) {
-    "use strict";
+window.addEventListener('converse-loaded', () => {
+    const mock = window.mock;
+    const test_utils = window.test_utils;
     const Strophe = converse.env.Strophe;
     const u = converse.env.utils;
     // See: https://xmpp.org/rfcs/rfc3921.html
@@ -294,5 +287,4 @@
             done();
         }));
     });
-}));
-
+});

+ 4 - 8
spec/protocol.js

@@ -1,10 +1,6 @@
-(function (root, factory) {
-    define([
-        "jasmine",
-        "mock",
-        "test-utils"], factory);
-} (this, function (jasmine, mock, test_utils) {
-    "use strict";
+window.addEventListener('converse-loaded', () => {
+    const mock = window.mock;
+    const test_utils = window.test_utils;
     const $iq = converse.env.$iq;
     const $pres = converse.env.$pres;
     const Strophe = converse.env.Strophe;
@@ -540,4 +536,4 @@
             }));
         });
     });
-}));
+});

+ 4 - 5
spec/push.js

@@ -1,7 +1,6 @@
-(function (root, factory) {
-    define(["jasmine", "mock", "test-utils"], factory);
-} (this, function (jasmine, mock, test_utils) {
-    "use strict";
+window.addEventListener('converse-loaded', () => {
+    const mock = window.mock;
+    const test_utils = window.test_utils;
     const $iq = converse.env.$iq;
     const Strophe = converse.env.Strophe;
     const _ = converse.env._;
@@ -189,4 +188,4 @@
             done();
         }));
     });
-}));
+});

+ 4 - 4
spec/register.js

@@ -1,6 +1,6 @@
-(function (root, factory) {
-    define(["jasmine", "mock", "test-utils"], factory);
-} (this, function (jasmine, mock, test_utils) {
+window.addEventListener('converse-loaded', () => {
+    const mock = window.mock;
+    const test_utils = window.test_utils;
     const Strophe = converse.env.Strophe;
     const $iq = converse.env.$iq;
     const { _, sizzle}  = converse.env;
@@ -362,4 +362,4 @@
             done();
         }));
     });
-}));
+});

+ 4 - 9
spec/retractions.js

@@ -1,11 +1,6 @@
-(function (root, factory) {
-    define([
-        "jasmine",
-        "mock",
-        "test-utils"
-        ], factory);
-} (this, function (jasmine, mock, test_utils) {
-    "use strict";
+window.addEventListener('converse-loaded', () => {
+    const mock = window.mock;
+    const test_utils = window.test_utils;
     const { Strophe, $iq } = converse.env;
     const u = converse.env.utils;
 
@@ -1157,4 +1152,4 @@
             }));
         });
     })
-}));
+});

+ 4 - 4
spec/room_registration.js

@@ -1,6 +1,6 @@
-(function (root, factory) {
-    define(["jasmine", "mock", "test-utils" ], factory);
-} (this, function (jasmine, mock, test_utils) {
+window.addEventListener('converse-loaded', () => {
+    const mock = window.mock;
+    const test_utils = window.test_utils;
     const _ = converse.env._,
           $iq = converse.env.$iq,
           Strophe = converse.env.Strophe,
@@ -118,4 +118,4 @@
             }));
         });
     });
-}));
+});

+ 4 - 4
spec/roomslist.js

@@ -1,6 +1,6 @@
-(function (root, factory) {
-    define(["jasmine", "mock", "test-utils"], factory);
-} (this, function (jasmine, mock, test_utils) {
+window.addEventListener('converse-loaded', () => {
+    const mock = window.mock;
+    const test_utils = window.test_utils;
     const { Strophe, $iq, $msg, $pres, sizzle, _ } = converse.env;
     const u = converse.env.utils;
 
@@ -330,4 +330,4 @@
             done();
         }));
     });
-}));
+});

+ 4 - 4
spec/roster.js

@@ -1,6 +1,6 @@
-(function (root, factory) {
-    define(["jasmine", "mock", "test-utils"], factory);
-} (this, function (jasmine, mock, test_utils) {
+window.addEventListener('converse-loaded', () => {
+    const mock = window.mock;
+    const test_utils = window.test_utils;
     const $iq = converse.env.$iq;
     const $pres = converse.env.$pres;
     const Strophe = converse.env.Strophe;
@@ -1317,4 +1317,4 @@
             }));
         });
     });
-}));
+});

+ 4 - 5
spec/smacks.js

@@ -1,7 +1,6 @@
-(function (root, factory) {
-    define(["jasmine", "mock", "test-utils"], factory);
-} (this, function (jasmine, mock, test_utils) {
-    "use strict";
+window.addEventListener('converse-loaded', () => {
+    const mock = window.mock;
+    const test_utils = window.test_utils;
     const $iq = converse.env.$iq;
     const $msg = converse.env.$msg;
     const Strophe = converse.env.Strophe;
@@ -280,4 +279,4 @@
             done();
         }));
     });
-}));
+});

+ 4 - 4
spec/spoilers.js

@@ -1,6 +1,6 @@
-(function (root, factory) {
-    define(["jasmine", "mock", "test-utils"], factory);
-} (this, function (jasmine, mock, test_utils) {
+window.addEventListener('converse-loaded', () => {
+    const mock = window.mock;
+    const test_utils = window.test_utils;
     const _ = converse.env._;
     const Strophe = converse.env.Strophe;
     const $msg = converse.env.$msg;
@@ -234,4 +234,4 @@
             done();
         }));
     });
-}));
+});

+ 4 - 9
spec/user-details-modal.js

@@ -1,11 +1,6 @@
-(function (root, factory) {
-    define([
-        "jasmine",
-        "mock",
-        "test-utils"
-        ], factory);
-} (this, function (jasmine, mock, test_utils) {
-    "use strict";
+window.addEventListener('converse-loaded', () => {
+    const mock = window.mock;
+    const test_utils = window.test_utils;
     const u = converse.env.utils;
 
     return describe("The User Details Modal", function () {
@@ -79,4 +74,4 @@
             done();
         }));
     });
-}));
+});

+ 4 - 6
spec/utils.js

@@ -1,8 +1,6 @@
-(function (root, factory) {
-    define(["jasmine"], factory);
-} (this, function () {
-    var utils = converse.env.utils,
-        _ = converse.env._;
+window.addEventListener('converse-loaded', () => {
+    const utils = converse.env.utils;
+    const _ = converse.env._;
 
     return describe("Converse.js Utilities", function() {
 
@@ -61,4 +59,4 @@
             expect(context.visible_toolbar_buttons.toggle_occupants).toBeTruthy();
         });
     });
-}));
+});

+ 3 - 4
spec/xmppstatus.js

@@ -1,6 +1,5 @@
-(function (root, factory) {
-    define(["jasmine", "mock"], factory);
-} (this, function (jasmine, mock) {
+window.addEventListener('converse-loaded', () => {
+    const mock = window.mock;
     const u = converse.env.utils;
 
     return describe("The XMPPStatus model", function () {
@@ -21,4 +20,4 @@
             done();
         }));
     });
-}));
+});

+ 4 - 4
spec/xss.js

@@ -1,6 +1,6 @@
-(function (root, factory) {
-    define(["jasmine", "mock", "test-utils" ], factory);
-} (this, function (jasmine, mock, test_utils) {
+window.addEventListener('converse-loaded', () => {
+    const mock = window.mock;
+    const test_utils = window.test_utils;
     const $pres = converse.env.$pres;
     const sizzle = converse.env.sizzle;
     const u = converse.env.utils;
@@ -241,4 +241,4 @@
             }));
         });
     });
-}));
+});

+ 129 - 22
tests.html

@@ -1,33 +1,140 @@
-<!DOCTYPE html>
-<html lang="en">
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+  "http://www.w3.org/TR/html4/loose.dtd">
+<html>
 <head>
-    <title>Converse.js</title>
-    <meta charset="utf-8">
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
-    <meta name="description" content="Converse.js: A free chat client for your website" />
-    <script src="3rdparty/libsignal-protocol.js"></script>
-    <link rel="manifest" href="./manifest.json">
-    <link rel="shortcut icon" type="image/ico" href="favicon.ico"/>
+    <title>Converse Tests</title>
+    <meta name="description" content="Converse XMPP Chat" />
     <link rel="shortcut icon" type="image/png" href="node_modules/jasmine-core/images/jasmine_favicon.png">
     <link rel="stylesheet" type="text/css" media="screen" href="node_modules/jasmine-core/lib/jasmine-core/jasmine.css">
-    <script data-main="tests/runner" src="../node_modules/requirejs/require.js"></script>
+    <link type="text/css" rel="stylesheet" media="screen" href="dist/website.css" />
+
+    <script src="tests/mock.js"></script>
+    <script src="tests/utils.js"></script>
+
+    <script src="node_modules/jasmine-core/lib/jasmine-core/jasmine.js"></script>
+    <script src="node_modules/jasmine-core/lib/jasmine-core/jasmine-html.js"></script>
+    <script src="node_modules/jasmine-core/lib/jasmine-core/boot.js"></script>
+    <script src="node_modules/sinon/pkg/sinon.js"></script>
+    <script src="tests/console-reporter.js"script>
+
+    <script src="spec/spoilers.js"></script>
+    <script src="spec/roomslist.js"></script>
+    <script src="spec/utils.js"></script>
+    <script src="spec/converse.js"></script>
+    <script src="spec/bookmarks.js"></script>
+    <script src="spec/headline.js"></script>
+    <script src="spec/disco.js"></script>
+    <script src="spec/protocol.js"></script>
+    <script src="spec/presence.js"></script>
+    <script src="spec/eventemitter.js"></script>
+    <script src="spec/smacks.js"></script>
+    <script src="spec/ping.js"></script>
+    <script src="spec/push.js"></script>
+    <script src="spec/xmppstatus.js"></script>
+    <script src="spec/mam.js"></script>
+    <script src="spec/omemo.js"></script>
+    <script src="spec/controlbox.js"></script>
+    <script src="spec/roster.js"></script>
+    <script src="spec/chatbox.js"></script>
+    <script src="spec/user-details-modal.js"></script>
+    <script src="spec/messages.js"></script>
+    <script src="spec/muc_messages.js"></script>
+    <script src="spec/retractions.js"></script>
+    <script src="spec/muc.js"></script>
+    <script src="spec/modtools.js"></script>
+    <script src="spec/room_registration.js"></script>
+    <script src="spec/autocomplete.js"></script>
+    <script src="spec/minchats.js"></script>
+    <script src="spec/notification.js"></script>
+    <script src="spec/login.js"></script>
+    <script src="spec/register.js"></script>
+    <script src="spec/hats.js"></script>
+    <script src="spec/http-file-upload.js"></script>
+    <script src="spec/emojis.js"></script>
+    <script src="spec/xss.js"></script>
+
     <style>
         .tests-brand-heading {
             margin-top: 1em;
             font-size: 200%;
         }
+        .jasmine_html-reporter {
+            text-align: left;
+            width: 100vw;
+            background-color: rgba(255, 255, 255, .5);
+        }
+
+        .intro {
+            background: unset;
+            background-color: #397491;
+        }
     </style>
 </head>
-<body class="reset"></body>
-    <div id="header_wrap" class="outer">
-        <header class="inner">
-          <h1 class="brand-heading tests-brand-heading">
-              <i class="icon-conversejs"></i> Converse</h1>
-          <h2 id="project_tagline">Tests</h2>
-        </header>
-    </div>
-    <script>
-        converse.load();
-    </script>
+
+<body id="page-top" data-spy="scroll" class="converse-website">
+
+<section class="section-wrapper">
+
+    <section id="intro" class="intro" class="container">
+        <div class="row">
+            <div class="col-md-12 col-md-offset-2">
+                <h1 class="brand-heading fade-in">
+                    <svg class="converse-svg-logo"
+                        xmlns:svg="http://www.w3.org/2000/svg"
+                        xmlns="http://www.w3.org/2000/svg"
+                        xmlns:xlink="http://www.w3.org/1999/xlink"
+                        viewBox="0 0 364 364">
+                    <title>Converse</title>
+                    <g class="cls-1" id="g904">
+                        <g data-name="Layer 2">
+                            <g data-name="Layer 7">
+                                <path
+                                    class="cls-3"
+                                    d="M221.46,103.71c0,18.83-29.36,18.83-29.12,0C192.1,84.88,221.46,84.88,221.46,103.71Z" />
+                                <path
+                                    class="cls-4"
+                                    d="M179.9,4.15A175.48,175.48,0,1,0,355.38,179.63,175.48,175.48,0,0,0,179.9,4.15Zm-40.79,264.5c-.23-17.82,27.58-17.82,27.58,0S138.88,286.48,139.11,268.65ZM218.6,168.24A79.65,79.65,0,0,1,205.15,174a12.76,12.76,0,0,0-6.29,4.65L167.54,222a1.36,1.36,0,0,1-2.46-.8v-35.8a2.58,2.58,0,0,0-3.06-2.53c-15.43,3-30.23,7.7-42.73,19.94-38.8,38-29.42,105.69,16.09,133.16a162.25,162.25,0,0,1-91.47-67.27C-3.86,182.26,34.5,47.25,138.37,25.66c46.89-9.75,118.25,5.16,123.73,62.83C265.15,120.64,246.56,152.89,218.6,168.24Z" />
+                            </g>
+                        </g>
+                    </g>
+                </svg>
+                <span class="brand-heading__text">
+                    <span>converse<span class="subdued">.js</span></span>
+                    <p class="byline">messaging freedom</p>
+                </span>
+                </h1>
+                <h2 id="project_tagline">Tests</h2>
+            </div>
+        </div>
+        <div class="row jasmine-output-container"></div>
+    </section>
+</body>
+  <script>
+      jasmine.DEFAULT_TIMEOUT_INTERVAL = 7000;
+      const env = jasmine.getEnv();
+      const queryString = new jasmine.QueryString({
+        getWindowLocation: () => window.location
+      });
+      env.clearReporters();
+
+      const htmlReporter = new jasmine.HtmlReporter({
+        env,
+        onRaiseExceptionsClick: () => { queryString.navigateWithNewParam("catch", !env.catchingExceptions()); },
+        onThrowExpectationsClick: () => { queryString.navigateWithNewParam("throwFailures", !env.throwingExpectationFailures()); },
+        onRandomClick: () => { queryString.navigateWithNewParam("random", !env.randomTests()); },
+        addToExistingQueryString: function(key, value) { return queryString.fullStringWithNewParam(key, value); },
+        getContainer: () => document.querySelector('.jasmine-output-container'),
+        createElement: function () { return document.createElement.apply(document, arguments); },
+        createTextNode: function () { return document.createTextNode.apply(document, arguments); },
+        timer: new jasmine.Timer(),
+        filterSpecs: !!queryString.getParam("spec")
+      });
+
+      //The `jsApiReporter` also receives spec results, and is used by any environment that needs to extract the results from JavaScript.
+      const jasmineInterface = jasmineRequire.interface(jasmine, env);
+      env.addReporter(jasmineInterface.jsApiReporter);
+      env.addReporter(htmlReporter);
+      env.addReporter(new ConsoleReporter());
+      converse.load();
+  </script>
 </html>

+ 116 - 122
tests/console-reporter.js

@@ -1,146 +1,140 @@
-(function (root, factory) {
-    define([], factory);
-} (this, function () {
-    "use strict";
+const noopTimer = {
+    start: function () {},
+    elapsed: function () { return 0; }
+};
+
+function ConsoleReporter () {
+    var timer = noopTimer,
+        specCount,
+        failureCount,
+        failedSpecs = [],
+        pendingCount,
+        ansi = {
+            green: '\x1B[32m',
+            red: '\x1B[31m',
+            yellow: '\x1B[33m',
+            none: '\x1B[0m'
+        },
+        failedSuites = [];
+
+    var print = function print (message) {
+        console.log(message + '\x03\b');
+    }
 
-    var noopTimer = {
-        start: function () {},
-        elapsed: function () { return 0; }
+    this.jasmineStarted = function () {
+        specCount = 0;
+        failureCount = 0;
+        pendingCount = 0;
+        print('Started');
+        printNewline();
+        timer.start();
     };
 
-    function ConsoleReporter (options) {
-        var timer = noopTimer,
-            specCount,
-            failureCount,
-            failedSpecs = [],
-            pendingCount,
-            ansi = {
-                green: '\x1B[32m',
-                red: '\x1B[31m',
-                yellow: '\x1B[33m',
-                none: '\x1B[0m'
-            },
-            failedSuites = [];
-
-        var print = function print (message) {
-            console.log(message + '\x03\b');
+    this.jasmineDone = function () {
+        print("jasmineDone");
+        printNewline();
+        for (var i = 0; i < failedSpecs.length; i++) {
+            specFailureDetails(failedSpecs[i]);
         }
 
-        this.jasmineStarted = function () {
-            specCount = 0;
-            failureCount = 0;
-            pendingCount = 0;
-            print('Started');
-            printNewline();
-            timer.start();
-        };
-
-        this.jasmineDone = function () {
-            print("jasmineDone");
-            printNewline();
-            for (var i = 0; i < failedSpecs.length; i++) {
-                specFailureDetails(failedSpecs[i]);
-            }
-
-            if(specCount > 0) {
-                printNewline();
-                var specCounts = specCount + ' ' + plural('spec', specCount) + ', ' +
-                        failureCount + ' ' + plural('failure', failureCount);
-                if (pendingCount) {
-                    specCounts += ', ' + pendingCount + ' pending ' + plural('spec', pendingCount);
-                }
-                print(specCounts);
-            } else {
-                print('No specs found');
-            }
-
-            printNewline();
-            var seconds = timer.elapsed() / 1000;
-            print('Finished in ' + seconds + ' ' + plural('second', seconds));
+        if(specCount > 0) {
             printNewline();
-            for (i = 0; i < failedSuites.length; i++) {
-                suiteFailureDetails(failedSuites[i]);
+            var specCounts = specCount + ' ' + plural('spec', specCount) + ', ' +
+                    failureCount + ' ' + plural('failure', failureCount);
+            if (pendingCount) {
+                specCounts += ', ' + pendingCount + ' pending ' + plural('spec', pendingCount);
             }
-            var exitCode = failureCount === 0 ? 0 : 1;
-            console.info('All tests completed!' + exitCode);
-        };
-
-        this.specDone = function (result) {
-            specCount++;
-            if (result.status == 'pending') {
-                pendingCount++;
-                print(colored('yellow', '*'));
-                return;
-            }
-            if (result.status == 'passed') {
-                print(colored('green', '.'));
-                return;
-            }
-            if (result.status == 'failed') {
-                failureCount++;
-                failedSpecs.push(result);
-                print(colored('red', 'F'));
-            }
-        };
-
-        this.suiteDone = function (result) {
-            if (result.failedExpectations && result.failedExpectations.length > 0) {
-                failureCount++;
-                failedSuites.push(result);
-            }
-        };
-        return this;
+            print(specCounts);
+        } else {
+            print('No specs found');
+        }
 
-        function printNewline() {
-            print('\n');
+        printNewline();
+        var seconds = timer.elapsed() / 1000;
+        print('Finished in ' + seconds + ' ' + plural('second', seconds));
+        printNewline();
+        for (i = 0; i < failedSuites.length; i++) {
+            suiteFailureDetails(failedSuites[i]);
         }
+        var exitCode = failureCount === 0 ? 0 : 1;
+        console.info('All tests completed!' + exitCode);
+    };
 
-        function colored (color, str) {
-            return ansi[color] + str + ansi.none;
+    this.specDone = function (result) {
+        specCount++;
+        if (result.status == 'pending') {
+            pendingCount++;
+            print(colored('yellow', '*'));
+            return;
+        }
+        if (result.status == 'passed') {
+            print(colored('green', '.'));
+            return;
         }
+        if (result.status == 'failed') {
+            failureCount++;
+            failedSpecs.push(result);
+            print(colored('red', 'F'));
+        }
+    };
 
-        function plural (str, count) {
-            return count == 1 ? str : str + 's';
+    this.suiteDone = function (result) {
+        if (result.failedExpectations && result.failedExpectations.length > 0) {
+            failureCount++;
+            failedSuites.push(result);
         }
+    };
+    return this;
 
-        function repeat (thing, times) {
-            var arr = [];
-            for (var i = 0; i < times; i++) {
-                arr.push(thing);
-            }
-            return arr;
+    function printNewline() {
+        print('\n');
+    }
+
+    function colored (color, str) {
+        return ansi[color] + str + ansi.none;
+    }
+
+    function plural (str, count) {
+        return count == 1 ? str : str + 's';
+    }
+
+    function repeat (thing, times) {
+        var arr = [];
+        for (var i = 0; i < times; i++) {
+            arr.push(thing);
         }
+        return arr;
+    }
 
-        function indent (str, spaces) {
-            var lines = (str || '').split('\n');
-            var newArr = [];
-            for (var i = 0; i < lines.length; i++) {
-                newArr.push(repeat(' ', spaces).join('') + lines[i]);
-            }
-            return newArr.join('\n');
+    function indent (str, spaces) {
+        var lines = (str || '').split('\n');
+        var newArr = [];
+        for (var i = 0; i < lines.length; i++) {
+            newArr.push(repeat(' ', spaces).join('') + lines[i]);
         }
+        return newArr.join('\n');
+    }
 
-        function specFailureDetails (result) {
-            printNewline();
-            print(result.fullName);
-            for (var i = 0; i < result.failedExpectations.length; i++) {
-                var failedExpectation = result.failedExpectations[i];
-                printNewline();
-                print(indent(failedExpectation.message, 2));
-                print(indent(failedExpectation.stack, 2));
-            }
+    function specFailureDetails (result) {
+        printNewline();
+        print(result.fullName);
+        for (var i = 0; i < result.failedExpectations.length; i++) {
+            var failedExpectation = result.failedExpectations[i];
             printNewline();
+            print(indent(failedExpectation.message, 2));
+            print(indent(failedExpectation.stack, 2));
         }
+        printNewline();
+    }
 
-        function suiteFailureDetails (result) {
-            for (var i = 0; i < result.failedExpectations.length; i++) {
-                printNewline();
-                print(colored('red', 'An error was thrown in an afterAll'));
-                printNewline();
-                print(colored('red', 'AfterAll ' + result.failedExpectations[i].message));
-            }
+    function suiteFailureDetails (result) {
+        for (var i = 0; i < result.failedExpectations.length; i++) {
+            printNewline();
+            print(colored('red', 'An error was thrown in an afterAll'));
             printNewline();
+            print(colored('red', 'AfterAll ' + result.failedExpectations[i].message));
         }
+        printNewline();
     }
-    return ConsoleReporter;
-}));
+}
+window.ConsoleReporter = ConsoleReporter;

+ 122 - 10
tests/index.html

@@ -8,23 +8,135 @@
     <link rel="stylesheet" type="text/css" media="screen" href="../node_modules/jasmine-core/lib/jasmine-core/jasmine.css">
     <link type="text/css" rel="stylesheet" media="screen" href="../dist/converse.css" />
     <script src="../dist/converse.js"></script>
-    <script data-main="runner" src="../node_modules/requirejs/require.js"></script>
+    <link type="text/css" rel="stylesheet" media="screen" href="../dist/website.css" />
+
+    <script src="../node_modules/jasmine-core/lib/jasmine-core/jasmine.js"></script>
+    <script src="../node_modules/jasmine-core/lib/jasmine-core/jasmine-html.js"></script>
+    <script src="../node_modules/jasmine-core/lib/jasmine-core/boot.js"></script>
+    <script src="../node_modules/sinon/pkg/sinon.js"></script>
+    <script src="console-reporter.js"></script>
+
+    <script src="../tests/mock.js"></script>
+    <script src="../tests/utils.js"></script>
+
+    <script src="../spec/spoilers.js"></script>
+    <script src="../spec/roomslist.js"></script>
+    <script src="../spec/utils.js"></script>
+    <script src="../spec/converse.js"></script>
+    <script src="../spec/bookmarks.js"></script>
+    <script src="../spec/headline.js"></script>
+    <script src="../spec/disco.js"></script>
+    <script src="../spec/protocol.js"></script>
+    <script src="../spec/presence.js"></script>
+    <script src="../spec/eventemitter.js"></script>
+    <script src="../spec/smacks.js"></script>
+    <script src="../spec/ping.js"></script>
+    <script src="../spec/push.js"></script>
+    <script src="../spec/xmppstatus.js"></script>
+    <script src="../spec/mam.js"></script>
+    <script src="../spec/omemo.js"></script>
+    <script src="../spec/controlbox.js"></script>
+    <script src="../spec/roster.js"></script>
+    <script src="../spec/chatbox.js"></script>
+    <script src="../spec/user-details-modal.js"></script>
+    <script src="../spec/messages.js"></script>
+    <script src="../spec/muc_messages.js"></script>
+    <script src="../spec/retractions.js"></script>
+    <script src="../spec/muc.js"></script>
+    <script src="../spec/modtools.js"></script>
+    <script src="../spec/room_registration.js"></script>
+    <script src="../spec/autocomplete.js"></script>
+    <script src="../spec/minchats.js"></script>
+    <script src="../spec/notification.js"></script>
+    <script src="../spec/login.js"></script>
+    <script src="../spec/register.js"></script>
+    <script src="../spec/hats.js"></script>
+    <script src="../spec/http-file-upload.js"></script>
+    <script src="../spec/emojis.js"></script>
+    <script src="../spec/xss.js"></script>
+
     <style>
         .tests-brand-heading {
             margin-top: 1em;
             font-size: 200%;
         }
+        .jasmine_html-reporter {
+            text-align: left;
+            width: 100vw;
+            background-color: rgba(255, 255, 255, .5);
+        }
+
+        .intro {
+            background: unset;
+            background-color: #397491;
+        }
     </style>
 </head>
 
-<body>
-    <div id="header_wrap" class="outer">
-        <header class="inner">
-          <h1 class="brand-heading tests-brand-heading">
-              <i class="icon-conversejs"></i> Converse</h1>
-          <h2 id="project_tagline">Tests</h2>
-        </header>
-    </div>
-    <script>converse.load();</script>
+<body id="page-top" data-spy="scroll" class="converse-website">
+
+<section class="section-wrapper">
+
+    <section id="intro" class="intro" class="container">
+        <div class="row">
+            <div class="col-md-12 col-md-offset-2">
+                <h1 class="brand-heading fade-in">
+                    <svg class="converse-svg-logo"
+                        xmlns:svg="http://www.w3.org/2000/svg"
+                        xmlns="http://www.w3.org/2000/svg"
+                        xmlns:xlink="http://www.w3.org/1999/xlink"
+                        viewBox="0 0 364 364">
+                    <title>Converse</title>
+                    <g class="cls-1" id="g904">
+                        <g data-name="Layer 2">
+                            <g data-name="Layer 7">
+                                <path
+                                    class="cls-3"
+                                    d="M221.46,103.71c0,18.83-29.36,18.83-29.12,0C192.1,84.88,221.46,84.88,221.46,103.71Z" />
+                                <path
+                                    class="cls-4"
+                                    d="M179.9,4.15A175.48,175.48,0,1,0,355.38,179.63,175.48,175.48,0,0,0,179.9,4.15Zm-40.79,264.5c-.23-17.82,27.58-17.82,27.58,0S138.88,286.48,139.11,268.65ZM218.6,168.24A79.65,79.65,0,0,1,205.15,174a12.76,12.76,0,0,0-6.29,4.65L167.54,222a1.36,1.36,0,0,1-2.46-.8v-35.8a2.58,2.58,0,0,0-3.06-2.53c-15.43,3-30.23,7.7-42.73,19.94-38.8,38-29.42,105.69,16.09,133.16a162.25,162.25,0,0,1-91.47-67.27C-3.86,182.26,34.5,47.25,138.37,25.66c46.89-9.75,118.25,5.16,123.73,62.83C265.15,120.64,246.56,152.89,218.6,168.24Z" />
+                            </g>
+                        </g>
+                    </g>
+                </svg>
+                <span class="brand-heading__text">
+                    <span>converse<span class="subdued">.js</span></span>
+                    <p class="byline">messaging freedom</p>
+                </span>
+                </h1>
+                <h2 id="project_tagline">Tests</h2>
+            </div>
+        </div>
+        <div class="row jasmine-output-container"></div>
+    </section>
 </body>
+  <script>
+      jasmine.DEFAULT_TIMEOUT_INTERVAL = 7000;
+      const env = jasmine.getEnv();
+      const queryString = new jasmine.QueryString({
+        getWindowLocation: () => window.location
+      });
+      env.clearReporters();
+
+      const htmlReporter = new jasmine.HtmlReporter({
+        env,
+        onRaiseExceptionsClick: () => { queryString.navigateWithNewParam("catch", !env.catchingExceptions()); },
+        onThrowExpectationsClick: () => { queryString.navigateWithNewParam("throwFailures", !env.throwingExpectationFailures()); },
+        onRandomClick: () => { queryString.navigateWithNewParam("random", !env.randomTests()); },
+        addToExistingQueryString: function(key, value) { return queryString.fullStringWithNewParam(key, value); },
+        getContainer: () => document.querySelector('.jasmine-output-container'),
+        createElement: function () { return document.createElement.apply(document, arguments); },
+        createTextNode: function () { return document.createTextNode.apply(document, arguments); },
+        timer: new jasmine.Timer(),
+        filterSpecs: !!queryString.getParam("spec")
+      });
+
+      //The `jsApiReporter` also receives spec results, and is used by any environment that needs to extract the results from JavaScript.
+      const jasmineInterface = jasmineRequire.interface(jasmine, env);
+      env.addReporter(jasmineInterface.jsApiReporter);
+      env.addReporter(htmlReporter);
+      env.addReporter(new ConsoleReporter());
+      converse.load();
+  </script>
 </html>

+ 36 - 41
tests/mock.js

@@ -1,6 +1,37 @@
-(function (root, factory) {
-    define("mock", [], factory);
-}(this, function () {
+const mock = {};
+window.mock = mock;
+let _converse, initConverse;
+
+mock.initConverse = function (promise_names=[], settings=null, func) {
+    if (typeof promise_names === "function") {
+        func = promise_names;
+        promise_names = []
+        settings = null;
+    }
+
+    return async done => {
+        if (_converse && _converse.api.connection.connected()) {
+            await _converse.api.user.logout();
+        }
+        const el = document.querySelector('#conversejs');
+        if (el) {
+            el.parentElement.removeChild(el);
+        }
+        document.title = "Converse Tests";
+
+        await initConverse(settings);
+        await Promise.all((promise_names || []).map(_converse.api.waitUntil));
+        try {
+            await func(done, _converse);
+        } catch(e) {
+            console.error(e);
+            fail(e);
+            await done();
+        }
+    }
+};
+
+window.addEventListener('converse-loaded', () => {
     const _ = converse.env._;
     const u = converse.env.utils;
     const Promise = converse.env.Promise;
@@ -24,7 +55,6 @@
             this.decryptPreKeyWhisperMessage = (key_and_tag) => {
                 return Promise.resolve(key_and_tag);
             };
-
             this.decryptWhisperMessage = (key_and_tag) => {
                 return Promise.resolve(key_and_tag);
             }
@@ -66,8 +96,6 @@
         }
     };
 
-    const mock = {};
-
     mock.default_muc_features = [
         'http://jabber.org/protocol/muc',
         'jabber:iq:register',
@@ -151,9 +179,6 @@
         'preventDefault': function () {}
     };
 
-
-    let _converse;
-
     const OriginalConnection = Strophe.Connection;
 
     function MockConnection (service, options) {
@@ -252,7 +277,7 @@
         window.sessionStorage.removeItem(cache_key+'fetched');
     }
 
-    async function initConverse (settings) {
+    initConverse = async (settings) => {
         clearStores();
         await clearIndexedDB();
 
@@ -309,34 +334,4 @@
         window.converse_disable_effects = true;
         return _converse;
     }
-
-    mock.initConverse = function (promise_names=[], settings=null, func) {
-        if (_.isFunction(promise_names)) {
-            func = promise_names;
-            promise_names = []
-            settings = null;
-        }
-
-        return async done => {
-            if (_converse && _converse.api.connection.connected()) {
-                await _converse.api.user.logout();
-            }
-            const el = document.querySelector('#conversejs');
-            if (el) {
-                el.parentElement.removeChild(el);
-            }
-            document.title = "Converse Tests";
-
-            await initConverse(settings);
-            await Promise.all((promise_names || []).map(_converse.api.waitUntil));
-            try {
-                await func(done, _converse);
-            } catch(e) {
-                console.error(e);
-                fail(e);
-                await done();
-            }
-        }
-    };
-    return mock;
-}));
+});

+ 0 - 94
tests/runner.js

@@ -1,94 +0,0 @@
-var config = {
-    baseUrl: '../',
-    paths: {
-        'console-reporter': 'tests/console-reporter',
-        'es6-promise': 'node_modules/es6-promise/dist/es6-promise.auto',
-        'jasmine-console': 'node_modules/jasmine-core/lib/console/console',
-        'jasmine-core': 'node_modules/jasmine-core/lib/jasmine-core/jasmine',
-        'jasmine-html': 'node_modules/jasmine-core/lib/jasmine-core/jasmine-html',
-        'jasmine':'node_modules/jasmine-core/lib/jasmine-core/boot',
-        'mock': 'tests/mock',
-        'sinon': 'node_modules/sinon/pkg/sinon',
-        'test-utils': 'tests/utils',
-        'transcripts': 'converse-logs/converse-logs'
-    },
-    shim: {
-        'jasmine-html': {
-            deps: ['jasmine-core'],
-            exports: 'window.jasmineRequire'
-        },
-        'jasmine-console': {
-            deps: ['jasmine-core'],
-            exports: 'window.jasmineRequire'
-        },
-        'jasmine': {
-            deps: ['jasmine-core', 'jasmine-html', 'jasmine-console'],
-            exports: 'window.jasmine'
-        },
-    }
-};
-require.config(config);
-
-var specs = [
-    "jasmine",
-    // "spec/transcripts",
-    // "spec/profiling",
-    "spec/spoilers",
-    "spec/roomslist",
-    "spec/utils",
-    "spec/converse",
-    "spec/bookmarks",
-    "spec/headline",
-    "spec/disco",
-    "spec/protocol",
-    "spec/presence",
-    "spec/eventemitter",
-    "spec/smacks",
-    "spec/ping",
-    "spec/push",
-    "spec/xmppstatus",
-    "spec/mam",
-    "spec/omemo",
-    "spec/controlbox",
-    "spec/roster",
-    "spec/chatbox",
-    "spec/user-details-modal",
-    "spec/messages",
-    "spec/muc_messages",
-    "spec/retractions",
-    "spec/muc",
-    "spec/modtools",
-    "spec/room_registration",
-    "spec/autocomplete",
-    "spec/minchats",
-    "spec/notification",
-    "spec/login",
-    "spec/register",
-    "spec/hats",
-    "spec/http-file-upload",
-    "spec/emojis",
-    "spec/xss"
-];
-
-
-function load () {
-    require(['console-reporter', 'mock', 'sinon'], (ConsoleReporter, mock, sinon) => {
-        if (window.view_mode) {
-            mock.view_mode = window.view_mode;
-        }
-        window.sinon = sinon;
-        // Load the specs
-        require(specs, jasmine => {
-            jasmine.DEFAULT_TIMEOUT_INTERVAL = 7000;
-            const jasmineEnv = jasmine.getEnv();
-            jasmineEnv.addReporter(new ConsoleReporter());
-            window.onload();
-        });
-    });
-}
-
-if (window.converse) {
-    load();
-} else {
-    window.addEventListener('converse-loaded', load);
-}

+ 16 - 16
tests/utils.js

@@ -1,6 +1,4 @@
-(function (root, factory) {
-    define(['mock'], factory);
-}(this, function (mock) {
+window.addEventListener('converse-loaded', () => {
     const _ = converse.env._;
     const $msg = converse.env.$msg;
     const $pres = converse.env.$pres;
@@ -8,8 +6,11 @@
     const Strophe = converse.env.Strophe;
     const sizzle = converse.env.sizzle;
     const u = converse.env.utils;
+    const mock = window.mock;
     const utils = {};
 
+    window.test_utils = utils;
+
     utils.waitUntilDiscoConfirmed = async function (_converse, entity_jid, identities, features=[], items=[], type='info') {
         const iq = await u.waitUntil(() => {
             return _.filter(
@@ -337,10 +338,10 @@
 
     utils.createContacts = async function (_converse, type, length) {
         /* Create current (as opposed to requesting or pending) contacts
-         * for the user's roster.
-         *
-         * These contacts are not grouped. See below.
-         */
+            * for the user's roster.
+            *
+            * These contacts are not grouped. See below.
+            */
         await _converse.api.waitUntil('rosterContactsFetched');
         let names, subscription, requesting, ask;
         if (type === 'requesting') {
@@ -414,13 +415,13 @@
 
     utils.createChatMessage = function (_converse, sender_jid, message) {
         return $msg({
-                   from: sender_jid,
-                   to: _converse.connection.jid,
-                   type: 'chat',
-                   id: (new Date()).getTime()
-               })
-               .c('body').t(message).up()
-               .c('active', {'xmlns': Strophe.NS.CHATSTATES}).tree();
+                    from: sender_jid,
+                    to: _converse.connection.jid,
+                    type: 'chat',
+                    id: (new Date()).getTime()
+                })
+                .c('body').t(message).up()
+                .c('active', {'xmlns': Strophe.NS.CHATSTATES}).tree();
     }
 
     utils.sendMessage = function (view, message) {
@@ -433,5 +434,4 @@
         });
         return promise;
     };
-    return utils;
-}));
+});