From 22b6f2774a89eca697588494114ee440dd27a535 Mon Sep 17 00:00:00 2001 From: Jordan Robinson Date: Wed, 3 Jan 2024 16:44:28 +0000 Subject: [PATCH] Readme update with new examples --- README.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/README.md b/README.md index 41cdd6a..57bfa66 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,38 @@ Clojure wrapper for the [Awaitility](http://www.awaitility.org/) Java library. (fn [] (>= (System/currentTimeMillis) end-time)))) ; function that will eventually return true ``` +### `at-least` parameter + +```clojure +;; Example of at-least parameter +(let [start-time (System/currentTimeMillis) + end-time (+ start-time 200)] + + (wait-for {:at-least [2 :seconds]} ; in this case we don't wait long enough + (fn [] (>= (System/currentTimeMillis) end-time)))) + +; this returns -> org.awaitility.core.ConditionTimeoutException: Condition was evaluated in 200 +; milliseconds which is earlier than expected minimum timeout 500 milliseconds +``` +### Poll intervals +```clojure +;; can do either: +(let [start-time (System/currentTimeMillis) + end-time (+ start-time 200)] + + (wait-for {:poll-interval [50 :milliseconds]} ; 50, 100, 150... milliseconds + (fn [] (>= (System/currentTimeMillis) end-time)))) + +;; or +(:import [org.awaitility.pollinterval FibonacciPollInterval]) + +(let [start-time (System/currentTimeMillis) + end-time (+ start-time 200)] + + (wait-for {:poll-interval (FibonacciPollInterval.)} ; 1, 1, 2, 3, 5, 8... milliseconds + (fn [] (>= (System/currentTimeMillis) end-time)))) +``` + ## License Copyright © 2024 Jordan Robinson