Skip to content

Commit

Permalink
fix tests (#287)
Browse files Browse the repository at this point in the history
* fix tests

* fix
  • Loading branch information
Uunnamed authored Aug 14, 2020
1 parent 0d120e7 commit 63e09d3
Showing 1 changed file with 25 additions and 20 deletions.
45 changes: 25 additions & 20 deletions test/etaoin/api_test2.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down

0 comments on commit 63e09d3

Please sign in to comment.