You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by hn...@apache.org on 2020/12/21 14:03:59 UTC

[myfaces-tobago] branch master updated: better errormessage for jasmine test tools

This is an automated email from the ASF dual-hosted git repository.

hnoeth pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git


The following commit(s) were added to refs/heads/master by this push:
     new c6eadac  better errormessage for jasmine test tools
c6eadac is described below

commit c6eadaca14681c475032fd4513871cc6a92e5034
Author: Henning Nöth <hn...@apache.org>
AuthorDate: Mon Dec 21 14:04:10 2020 +0100

    better errormessage for jasmine test tools
    
    * better errormessage if the element attribute of  event(type, element, result) is no function
---
 .../resources/tobago/test/tobago-test-tool.js      | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/tobago-tool/tobago-tool-test/src/main/resources/META-INF/resources/tobago/test/tobago-test-tool.js b/tobago-tool/tobago-tool-test/src/main/resources/META-INF/resources/tobago/test/tobago-test-tool.js
index 13e6d73..0fe3a2e 100644
--- a/tobago-tool/tobago-tool-test/src/main/resources/META-INF/resources/tobago/test/tobago-test-tool.js
+++ b/tobago-tool/tobago-tool-test/src/main/resources/META-INF/resources/tobago/test/tobago-test-tool.js
@@ -273,15 +273,19 @@ class JasmineTestTool {
    * @param result function
    */
   event(type, element, result) {
-    this.do(() => {
-      if (result()) {
-        fail("The result function (" + result + ") returns true BEFORE the '" + type + "' event is dispatched."
-            + " Please define a result function that return false before dispatch event and return true after dispatch"
-            + " event.");
-      }
-    });
-    this.do(() => element().dispatchEvent(new Event(type, {bubbles: true})));
-    this.wait(result);
+    if (typeof element === "function") {
+      this.do(() => {
+        if (result()) {
+          fail("The result function (" + result + ") returns true BEFORE the '" + type + "' event is dispatched."
+              + " Please define a result function that return false before dispatch event and return true after" +
+              " dispatch event.");
+        }
+      });
+      this.do(() => element().dispatchEvent(new Event(type, {bubbles: true})));
+      this.wait(result);
+    } else {
+      fail("event(type, element, result); 'element' must be a function but was: " + element);
+    }
   }
 
   do(fn) {