浏览代码

Add ability to run tests for transpiled code

JC Brand 7 年之前
父节点
当前提交
f724f49087
共有 8 个文件被更改,包括 152 次插入10 次删除
  1. 2 2
      css/converse.css
  2. 2 2
      css/inverse.css
  3. 2 2
      index.html
  4. 1 1
      sass/_controlbox.scss
  5. 3 0
      src/converse-controlbox.js
  6. 8 3
      src/converse-dragresize.js
  7. 100 0
      tests/runner-transpiled.js
  8. 34 0
      transpiled_tests.html

+ 2 - 2
css/converse.css

@@ -1002,7 +1002,7 @@
     /* rgba supported */
     /* rgba supported */
     border: 1px solid #999;
     border: 1px solid #999;
     /*IE 6/7/8*/
     /*IE 6/7/8*/
-    border: none transparent;
+    border: none rgba(0, 0, 0, 0);
     /*IE9 + everything else*/
     /*IE9 + everything else*/
     background-color: #E6E6E6;
     background-color: #E6E6E6;
     text-decoration: none;
     text-decoration: none;
@@ -2282,7 +2282,7 @@
     float: right; }
     float: right; }
   #conversejs #controlbox .controlbox-panes {
   #conversejs #controlbox .controlbox-panes {
     height: 100%;
     height: 100%;
-    overflow-y: scroll; }
+    overflow-y: auto; }
   #conversejs #controlbox .controlbox-pane {
   #conversejs #controlbox .controlbox-pane {
     padding: 1em;
     padding: 1em;
     background-color: white;
     background-color: white;

+ 2 - 2
css/inverse.css

@@ -1002,7 +1002,7 @@
     /* rgba supported */
     /* rgba supported */
     border: 1px solid #999;
     border: 1px solid #999;
     /*IE 6/7/8*/
     /*IE 6/7/8*/
-    border: none transparent;
+    border: none rgba(0, 0, 0, 0);
     /*IE9 + everything else*/
     /*IE9 + everything else*/
     background-color: #E6E6E6;
     background-color: #E6E6E6;
     text-decoration: none;
     text-decoration: none;
@@ -2368,7 +2368,7 @@ body {
     float: right; }
     float: right; }
   #conversejs #controlbox .controlbox-panes {
   #conversejs #controlbox .controlbox-panes {
     height: 100%;
     height: 100%;
-    overflow-y: scroll; }
+    overflow-y: auto; }
   #conversejs #controlbox .controlbox-pane {
   #conversejs #controlbox .controlbox-pane {
     padding: 1.2em;
     padding: 1.2em;
     background-color: white;
     background-color: white;

+ 2 - 2
index.html

@@ -16,8 +16,8 @@
     <noscript><p><img src="//stats.opkode.com/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript>
     <noscript><p><img src="//stats.opkode.com/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript>
     <script src="src/website.js"></script>
     <script src="src/website.js"></script>
     <![if gte IE 11]>
     <![if gte IE 11]>
-        <link type="text/css" rel="stylesheet" media="screen" href="https://cdn.conversejs.org/3.3.1/css/converse.min.css" />
-        <script src="https://cdn.conversejs.org/3.3.1/dist/converse.min.js"></script>
+        <link type="text/css" rel="stylesheet" media="screen" href="css/converse.css" />
+        <script src="dist/converse.js"></script>
     <![endif]>
     <![endif]>
 </head>
 </head>
 
 

+ 1 - 1
sass/_controlbox.scss

@@ -454,7 +454,7 @@
 
 
         .controlbox-panes {
         .controlbox-panes {
             height: 100%;
             height: 100%;
-            overflow-y: scroll;
+            overflow-y: auto;
         }
         }
 
 
         .controlbox-pane {
         .controlbox-pane {

+ 3 - 0
src/converse-controlbox.js

@@ -597,6 +597,9 @@
 
 
                 renderTab () {
                 renderTab () {
                     const controlbox = _converse.chatboxes.get('controlbox');
                     const controlbox = _converse.chatboxes.get('controlbox');
+                    if (_.isNil(controlbox)) {
+                        return;
+                    }
                     const chats = fp.filter(_.partial(u.isOfType, CHATBOX_TYPE), _converse.chatboxes.models);
                     const chats = fp.filter(_.partial(u.isOfType, CHATBOX_TYPE), _converse.chatboxes.models);
                     this.tab_el.innerHTML = tpl_contacts_tab({
                     this.tab_el.innerHTML = tpl_contacts_tab({
                         'label_contacts': LABEL_CONTACTS,
                         'label_contacts': LABEL_CONTACTS,

+ 8 - 3
src/converse-dragresize.js

@@ -175,7 +175,10 @@
                     } else {
                     } else {
                         height = "";
                         height = "";
                     }
                     }
-                    this.el.querySelector('.box-flyout').style.height = height;
+                    const flyout_el = this.el.querySelector('.box-flyout');
+                    if (!_.isNull(flyout_el)) {
+                        flyout_el.style.height = height;
+                    }
                 },
                 },
 
 
                 setChatBoxWidth (width) {
                 setChatBoxWidth (width) {
@@ -186,10 +189,12 @@
                         width = "";
                         width = "";
                     }
                     }
                     this.el.style.width = width;
                     this.el.style.width = width;
-                    this.el.querySelector('.box-flyout').style.width = width;
+                    const flyout_el = this.el.querySelector('.box-flyout');
+                    if (!_.isNull(flyout_el)) {
+                        flyout_el.style.width = width;
+                    }
                 },
                 },
 
 
-
                 adjustToViewport () {
                 adjustToViewport () {
                     /* Event handler called when viewport gets resized. We remove
                     /* Event handler called when viewport gets resized. We remove
                      * custom width/height from chat boxes.
                      * custom width/height from chat boxes.

+ 100 - 0
tests/runner-transpiled.js

@@ -0,0 +1,100 @@
+/*global config */
+
+// Extra test dependencies
+config.paths.jquery = "node_modules/jquery/dist/jquery";
+config.paths.mock = "tests/mock";
+config.paths['wait-until-promise'] = "node_modules/wait-until-promise/index";
+config.paths['test-utils'] = "tests/utils";
+config.paths.sinon = "node_modules/sinon/pkg/sinon";
+config.paths.transcripts = "converse-logs/converse-logs";
+config.paths["jasmine-core"] = "node_modules/jasmine-core/lib/jasmine-core/jasmine";
+config.paths.jasmine = "node_modules/jasmine-core/lib/jasmine-core/boot";
+config.paths["jasmine-console"] = "node_modules/jasmine-core/lib/console/console";
+config.paths["console-reporter"] = "tests/console-reporter";
+config.paths["jasmine-html"] = "node_modules/jasmine-core/lib/jasmine-core/jasmine-html";
+
+config.paths.converse =                 "builds/converse";
+config.paths.utils =                    "builds/utils";
+config.paths["converse-bookmarks"] =    "builds/converse-bookmarks";
+config.paths["converse-chatboxes"] =    "builds/converse-chatboxes";
+config.paths["converse-chatview"] =     "builds/converse-chatview";
+config.paths["converse-controlbox"] =   "builds/converse-controlbox";
+config.paths["converse-core"] =         "builds/converse-core";
+config.paths["converse-disco"] =        "builds/converse-disco";
+config.paths["converse-dragresize"] =   "builds/converse-dragresize";
+config.paths["converse-headline"] =     "builds/converse-headline";
+config.paths["converse-fullscreen"] =   "builds/converse-fullscreen";
+config.paths["converse-mam"] =          "builds/converse-mam";
+config.paths["converse-minimize"] =     "builds/converse-minimize";
+config.paths["converse-muc"] =          "builds/converse-muc";
+config.paths["converse-muc-embedded"] = "builds/converse-muc-embedded";
+config.paths["converse-notification"] = "builds/converse-notification";
+config.paths["converse-otr"] =          "builds/converse-otr";
+config.paths["converse-ping"] =         "builds/converse-ping";
+config.paths["converse-profile"] =      "builds/converse-profile";
+config.paths["converse-register"] =     "builds/converse-register";
+config.paths["converse-roomslist"] =    "builds/converse-roomslist";
+config.paths["converse-rosterview"] =   "builds/converse-rosterview";
+config.paths["converse-singleton"] =    "builds/converse-singleton";
+config.paths["converse-vcard"] =        "builds/converse-vcard";
+
+
+config.shim.jasmine = {
+    exports: 'window.jasmineRequire'
+};
+config.shim['jasmine-html'] = {
+    deps: ['jasmine-core'],
+    exports: 'window.jasmineRequire'
+};
+config.shim['jasmine-console'] = {
+    deps: ['jasmine-core'],
+    exports: 'window.jasmineRequire'
+};
+config.shim.jasmine = {
+    deps: ['jasmine-core', 'jasmine-html', 'jasmine-console'],
+    exports: 'window.jasmine'
+};
+require.config(config);
+
+var specs = [
+    "jasmine",
+    //"spec/transcripts",
+    "spec/profiling",
+    "spec/utils",
+    "spec/converse",
+    "spec/bookmarks",
+    "spec/roomslist",
+    "spec/headline",
+    "spec/disco",
+    "spec/protocol",
+    "spec/presence",
+    "spec/eventemitter",
+    "spec/ping",
+    "spec/xmppstatus",
+    "spec/mam",
+    "spec/otr",
+    "spec/controlbox",
+    "spec/roster",
+    "spec/chatbox",
+    "spec/chatroom",
+    "spec/minchats",
+    "spec/notification",
+    "spec/register"
+];
+
+require(['console-reporter', 'mock', 'sinon', 'wait-until-promise', 'pluggable'],
+        function(ConsoleReporter, mock, sinon, waitUntilPromise, pluggable) {
+    window.sinon = sinon;
+    waitUntilPromise.setPromiseImplementation(window.Promise);
+    window.waitUntilPromise = waitUntilPromise.default;
+
+    window.localStorage.clear();
+    window.sessionStorage.clear();
+
+    // Load the specs
+    require(specs, function (jasmine) {
+        var jasmineEnv = jasmine.getEnv();
+        jasmineEnv.addReporter(new ConsoleReporter());
+        window.onload();
+    });
+});

+ 34 - 0
transpiled_tests.html

@@ -0,0 +1,34 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+  "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+    <title>Converse.js Tests</title>
+    <meta name="description" content="Converse.js: A chat client for your website" />
+    <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">
+    <link rel="stylesheet" type="text/css" media="screen" href="css/jasmine.css">
+    <link type="text/css" rel="stylesheet" media="screen" href="css/theme.css" />
+    <link type="text/css" rel="stylesheet" media="screen" href="css/converse.css" />
+
+    <script src="src/config.js"></script>
+    <script data-main="tests/runner-transpiled" src="node_modules/requirejs/require.js"></script>
+
+    <style>
+        .tests-brand-heading {
+            margin-top: 1em;
+            font-size: 200%;
+        }
+    </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.js</h1>
+          <h2 id="project_tagline">Tests</h2>
+        </header>
+    </div>
+</body>
+</html>