diff --git a/index.html b/index.html index 1d6b45e33..67800d495 100644 --- a/index.html +++ b/index.html @@ -13,7 +13,6 @@ - diff --git a/package-lock.json b/package-lock.json index 13164b1f6..30d72cd49 100644 --- a/package-lock.json +++ b/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", diff --git a/package.json b/package.json index 117008463..80901ae8b 100644 --- a/package.json +++ b/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", diff --git a/spec/autocomplete.js b/spec/autocomplete.js index 181d5c6e4..3cb7e9ebc 100644 --- a/spec/autocomplete.js +++ b/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(); })); }); -})); +}); diff --git a/spec/bookmarks.js b/spec/bookmarks.js index 4c05bcd16..20d52cedb 100644 --- a/spec/bookmarks.js +++ b/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(); })); }); -})); +}); diff --git a/spec/chatbox.js b/spec/chatbox.js index 86ab22e64..f947ebc8d 100644 --- a/spec/chatbox.js +++ b/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 @@ })); }); }); -})); +}); diff --git a/spec/controlbox.js b/spec/controlbox.js index 3c5165339..6ae4ac5e4 100644 --- a/spec/controlbox.js +++ b/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(); })); }); -})); +}); diff --git a/spec/converse.js b/spec/converse.js index 6cbaaf065..1407bdfc2 100644 --- a/spec/converse.js +++ b/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 @@ }); }); }); -})); +}); diff --git a/spec/disco.js b/spec/disco.js index 657b854e1..ea76bae59 100644 --- a/spec/disco.js +++ b/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 @@ })); }); }); -})); +}); diff --git a/spec/emojis.js b/spec/emojis.js index f9f9eed56..6163cc7e0 100644 --- a/spec/emojis.js +++ b/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 @@ })); }); }); -})); +}); diff --git a/spec/eventemitter.js b/spec/eventemitter.js index f6b2960d2..5107cd52b 100644 --- a/spec/eventemitter.js +++ b/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(); })); }); -})); +}); diff --git a/spec/hats.js b/spec/hats.js index 819b61b94..ee3b97c35 100644 --- a/spec/hats.js +++ b/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(); })); }) -})); +}); diff --git a/spec/headline.js b/spec/headline.js index c24f96701..dc1481fa2 100644 --- a/spec/headline.js +++ b/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(); })); }); -})); +}); diff --git a/spec/http-file-upload.js b/spec/http-file-upload.js index 06d1050af..1ad70c97a 100644 --- a/spec/http-file-upload.js +++ b/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 @@ }); }); }); -})); +}); diff --git a/spec/login.js b/spec/login.js index 7cc47fd31..52174910d 100644 --- a/spec/login.js +++ b/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 @@ }); })); }); -})); +}); diff --git a/spec/mam.js b/spec/mam.js index 643041972..3e5f69f70 100644 --- a/spec/mam.js +++ b/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 @@ })); }); }); -})); +}); diff --git a/spec/messages.js b/spec/messages.js index 64f81dff8..bb4078f64 100644 --- a/spec/messages.js +++ b/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(); })); }); -})); +}); diff --git a/spec/minchats.js b/spec/minchats.js index 9ba57e85a..4e05c6118 100644 --- a/spec/minchats.js +++ b/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(); })); }); -})); +}); diff --git a/spec/modtools.js b/spec/modtools.js index 8ec6e2a3c..82915a0c8 100644 --- a/spec/modtools.js +++ b/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(); })); }); -})); +}); diff --git a/spec/muc.js b/spec/muc.js index b32688e62..831aa35c3 100644 --- a/spec/muc.js +++ b/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 @@ })); }); }); -})); +}); diff --git a/spec/muc_messages.js b/spec/muc_messages.js index b5b1ab4e4..645450931 100644 --- a/spec/muc_messages.js +++ b/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 @@ })); }); }); -})); +}); diff --git a/spec/notification.js b/spec/notification.js index e4fe118f3..3c4d9951d 100644 --- a/spec/notification.js +++ b/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 @@ }); }); }); -})); +}); diff --git a/spec/omemo.js b/spec/omemo.js index 8b65eb891..ff11946c7 100644 --- a/spec/omemo.js +++ b/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(); })); }); -})); +}); diff --git a/spec/ping.js b/spec/ping.js index 8a84df432..6601caeb6 100644 --- a/spec/ping.js +++ b/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 @@ })); }); }); -})); +}); diff --git a/spec/presence.js b/spec/presence.js index 74cad97e6..fffff89fd 100644 --- a/spec/presence.js +++ b/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(); })); }); -})); - +}); diff --git a/spec/protocol.js b/spec/protocol.js index 43ff250b7..bfe652439 100644 --- a/spec/protocol.js +++ b/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 @@ })); }); }); -})); +}); diff --git a/spec/push.js b/spec/push.js index baa2b911c..ccfc37d46 100644 --- a/spec/push.js +++ b/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(); })); }); -})); +}); diff --git a/spec/register.js b/spec/register.js index 72c0417d0..3ee5600d0 100644 --- a/spec/register.js +++ b/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(); })); }); -})); +}); diff --git a/spec/retractions.js b/spec/retractions.js index 9cfbcb8f9..ccabd6d95 100644 --- a/spec/retractions.js +++ b/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 @@ })); }); }) -})); +}); diff --git a/spec/room_registration.js b/spec/room_registration.js index 60cb0664c..b853a8c3d 100644 --- a/spec/room_registration.js +++ b/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 @@ })); }); }); -})); +}); diff --git a/spec/roomslist.js b/spec/roomslist.js index 9fc5882ab..a27f36129 100644 --- a/spec/roomslist.js +++ b/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(); })); }); -})); +}); diff --git a/spec/roster.js b/spec/roster.js index f0e0b39aa..839a39461 100644 --- a/spec/roster.js +++ b/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 @@ })); }); }); -})); +}); diff --git a/spec/smacks.js b/spec/smacks.js index 66b501e75..737199658 100644 --- a/spec/smacks.js +++ b/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(); })); }); -})); +}); diff --git a/spec/spoilers.js b/spec/spoilers.js index fe5bbf88f..36ee6d78d 100644 --- a/spec/spoilers.js +++ b/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(); })); }); -})); +}); diff --git a/spec/user-details-modal.js b/spec/user-details-modal.js index 705a07034..552e88116 100644 --- a/spec/user-details-modal.js +++ b/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(); })); }); -})); +}); diff --git a/spec/utils.js b/spec/utils.js index ccc963cf4..3045a72f0 100644 --- a/spec/utils.js +++ b/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(); }); }); -})); +}); diff --git a/spec/xmppstatus.js b/spec/xmppstatus.js index 2522195f6..f2ee79438 100644 --- a/spec/xmppstatus.js +++ b/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(); })); }); -})); +}); diff --git a/spec/xss.js b/spec/xss.js index ca6375d40..38bbab3d5 100644 --- a/spec/xss.js +++ b/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 @@ })); }); }); -})); +}); diff --git a/tests.html b/tests.html index bb0b055bb..898f3b0eb 100644 --- a/tests.html +++ b/tests.html @@ -1,33 +1,140 @@ - - + + - Converse.js - - - - - - - + Converse Tests + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - -
-
-

- Converse

-

Tests

-
-
- + + + +
+ +
+
+
+

+ + + converse.js + + +

+

Tests

+
+
+
+
+ + diff --git a/tests/console-reporter.js b/tests/console-reporter.js index 01ce51fdc..06a928aaf 100644 --- a/tests/console-reporter.js +++ b/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; } +}; - var 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'); + } + + 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'); + if(specCount > 0) { printNewline(); - timer.start(); - }; - - this.jasmineDone = function () { - print("jasmineDone"); - printNewline(); - for (var i = 0; i < failedSpecs.length; i++) { - specFailureDetails(failedSpecs[i]); + var specCounts = specCount + ' ' + plural('spec', specCount) + ', ' + + failureCount + ' ' + plural('failure', failureCount); + if (pendingCount) { + specCounts += ', ' + pendingCount + ' pending ' + plural('spec', pendingCount); } - - 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)); - printNewline(); - for (i = 0; i < failedSuites.length; i++) { - suiteFailureDetails(failedSuites[i]); - } - 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; - - function printNewline() { - print('\n'); + print(specCounts); + } else { + print('No specs found'); } - function colored (color, str) { - return ansi[color] + str + ansi.none; + 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 plural (str, count) { - return count == 1 ? str : str + 's'; + 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 repeat (thing, times) { - var arr = []; - for (var i = 0; i < times; i++) { - arr.push(thing); - } - return arr; + this.suiteDone = function (result) { + if (result.failedExpectations && result.failedExpectations.length > 0) { + failureCount++; + failedSuites.push(result); } + }; + return this; - 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)); - } - 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)); - } - printNewline(); - } + function printNewline() { + print('\n'); } - return ConsoleReporter; -})); + + 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 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)); + } + printNewline(); + } +} +window.ConsoleReporter = ConsoleReporter; diff --git a/tests/index.html b/tests/index.html index e7fe0642a..5dfd9b1eb 100644 --- a/tests/index.html +++ b/tests/index.html @@ -8,23 +8,135 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - -
-
-

- Converse

-

Tests

-
-
- + + +
+ +
+
+
+

+ + + converse.js + + +

+

Tests

+
+
+
+
+ diff --git a/tests/mock.js b/tests/mock.js index 12e9b45aa..f6395dbc4 100644 --- a/tests/mock.js +++ b/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; -})); +}); diff --git a/tests/runner.js b/tests/runner.js deleted file mode 100644 index 161539ed9..000000000 --- a/tests/runner.js +++ /dev/null @@ -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); -} diff --git a/tests/utils.js b/tests/utils.js index 89e604a40..5cbd6ad96 100644 --- a/tests/utils.js +++ b/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; -})); +});