Add the ability to run tests via the webpack devserver

This commit is contained in:
JC Brand 2020-04-21 20:17:46 +02:00
parent 65246d0041
commit 7eb6a17fd2
6 changed files with 60 additions and 16 deletions

View File

@ -28,7 +28,6 @@ const $iq = strophe.default.$iq;
const $msg = strophe.default.$msg; const $msg = strophe.default.$msg;
const $pres = strophe.default.$pres; const $pres = strophe.default.$pres;
dayjs.extend(advancedFormat); dayjs.extend(advancedFormat);
// Add Strophe Namespaces // Add Strophe Namespaces

33
tests.html Normal file
View File

@ -0,0 +1,33 @@
<!DOCTYPE html>
<html lang="en">
<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"/>
<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>
<style>
.tests-brand-heading {
margin-top: 1em;
font-size: 200%;
}
</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>
</html>

View File

@ -25,5 +25,6 @@
<h2 id="project_tagline">Tests</h2> <h2 id="project_tagline">Tests</h2>
</header> </header>
</div> </div>
<script>converse.load();</script>
</body> </body>
</html> </html>

View File

@ -1,9 +1,6 @@
(function (root, factory) { (function (root, factory) {
define("mock", [], factory); define("mock", [], factory);
}(this, function () { }(this, function () {
converse.load();
const _ = converse.env._; const _ = converse.env._;
const u = converse.env.utils; const u = converse.env.utils;
const Promise = converse.env.Promise; const Promise = converse.env.Promise;

View File

@ -70,6 +70,8 @@ var specs = [
"spec/xss" "spec/xss"
]; ];
function load () {
require(['console-reporter', 'mock', 'sinon'], (ConsoleReporter, mock, sinon) => { require(['console-reporter', 'mock', 'sinon'], (ConsoleReporter, mock, sinon) => {
if (window.view_mode) { if (window.view_mode) {
mock.view_mode = window.view_mode; mock.view_mode = window.view_mode;
@ -83,3 +85,10 @@ require(['console-reporter', 'mock', 'sinon'], (ConsoleReporter, mock, sinon) =>
window.onload(); window.onload();
}); });
}); });
}
if (window.converse) {
load();
} else {
window.addEventListener('converse-loaded', load);
}

View File

@ -13,6 +13,11 @@ module.exports = merge(common, {
new HTMLWebpackPlugin({ new HTMLWebpackPlugin({
title: 'Converse.js Dev', title: 'Converse.js Dev',
template: 'webpack.html' template: 'webpack.html'
}),
new HTMLWebpackPlugin({
filename: 'tests.html',
title: 'Converse.js Tests',
template: 'tests.html'
}) })
], ],
}); });