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/04/21 21:01:10 UTC

[myfaces-tobago] 01/02: improve 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

commit e9e5f55a793df38c391d507297287920dc5bee3b
Author: Henning Nöth <hn...@apache.org>
AuthorDate: Tue Apr 21 22:03:46 2020 +0200

    improve jasmine test tools
    
    * implement setup method
---
 .../resources/tobago/test/tobago-test-tool.js      | 23 ++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 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 a9185b3..47cb35c 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
@@ -239,12 +239,31 @@ class JasmineTestTool {
   timeout;
   lastStepExecution;
 
+  /**
+   * @param done function from Jasmine; must called if all Steps done or timeout
+   * @param timeout for a single step; default 20000ms
+   */
   constructor(done, timeout) {
-    this.done = done; //done function from Jasmine; must called if all Steps done or timeout
-    this.timeout = timeout ? timeout : 20000; //timeout for a single step
+    this.done = done;
+    this.timeout = timeout ? timeout : 20000;
     this.registerAjaxReadyStateListener();
   }
 
+  /**
+   * The condition function (fn1) defines the desired state before the main test starts. The do function (fn2) will be
+   * executed if the condition function returns false.
+   * @param fn1 condition function
+   * @param fn2 do function
+   */
+  setup(fn1, fn2) {
+    this.do(() => {
+      if (!fn1()) {
+        fn2();
+      }
+    })
+    this.wait(fn1);
+  }
+
   do(fn) {
     this.steps.push({
       type: "do",