diff --git a/test/etaoin/api_test2.clj b/test/etaoin/api_test2.clj index 739bc922..2928201c 100644 --- a/test/etaoin/api_test2.clj +++ b/test/etaoin/api_test2.clj @@ -3,26 +3,31 @@ [etaoin.proc] [clojure.test :refer :all])) -#_(deftest test-firefox-driver-args - (let [args (atom [])] - (with-redefs-fn {#'etaoin.proc/run (fn [a _] (reset! args a))} - #(do (testing "No custom args" - (-> (create-driver :firefox {:port 1234}) - (run-driver {})) - (is (= @args - ["geckodriver" "--port" 1234]))) - (testing "Default `--marionette-port` is assigned when `:profile` is specified" - (-> (create-driver :firefox {:port 1234}) - (run-driver {:profile "/tmp/firefox-profile/1"})) - (is (= @args - ["geckodriver" "--port" 1234 "--marionette-port" 2828]))) - (testing "Custom `--marionette-port` is assigned when `:profile` is specified" - (-> (create-driver :firefox {:port 1234}) - (run-driver {:profile "/tmp/firefox-profile/1" - :args-driver ["--marionette-port" 2821]})) - (is (= @args - ["geckodriver" "--port" 1234 "--marionette-port" 2821]))))))) - +(deftest test-firefox-driver-args + (with-redefs + [etaoin.proc/run (fn [_ _]) + wait-running identity + create-session (fn [_ _] "session-key") + etaoin.proc/kill identity + delete-session identity] + (testing "Session" + (with-firefox {} driver + (is (= "session-key" + (:session @driver))))) + (testing "No custom args" + (with-firefox {:port 1234} driver + (is (= ["geckodriver" "--port" 1234] + (:args @driver))))) + (testing "Default `--marionette-port` is assigned when `:profile` is specified" + (with-firefox {:port 1234 :profile "/tmp/firefox-profile/1"} driver + (is (= ["geckodriver" "--port" 1234 "--marionette-port" 2828] + (:args @driver))))) + (testing "Custom `--marionette-port` is assigned when `:profile` is specified" + (with-firefox {:port 1234 + :profile "/tmp/firefox-profile/1" + :args-driver ["--marionette-port" 2821]} driver + (is (= ["geckodriver" "--port" 1234 "--marionette-port" 2821] + (:args @driver))))))) (deftest test-fail-run-driver (is (thrown-with-msg?