Skip to content

Commit

Permalink
Added simple test for monitor-dashboard function
Browse files Browse the repository at this point in the history
Using clojure.string/includes? to see if the result of calling the
monitor-dashboard function includes specific sub-strings.

This could be done using the mock framework and put into a let to make the code
cleaner.
  • Loading branch information
practicalli-johnny committed Sep 23, 2018
1 parent f5eed17 commit d2016c0
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/status_monitor/handler_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,22 @@
:fill "orange"}]]]
(is (= (component-status-bar 50)
component-50-per-cent)))))

(deftest test-monitor-dashboard
(testing "Test dashboard contains key pieces of information"
(is (clojure.string/includes?
(monitor-dashboard {})
"<title>Area51 Mock Status</title>"))
(is (clojure.string/includes?
(monitor-dashboard {})
"<link href=\"//stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css\" rel=\"stylesheet\" type=\"text/css\">"))
(is (clojure.string/includes?
(monitor-dashboard {}) "<div class=\"jumbotron\"><h1>Mock Status Monitor Dashboard</h1></div>"))
(is (clojure.string/includes?
(monitor-dashboard {}) "<h2>Application monitor</h2>"))
(is (clojure.string/includes?
(monitor-dashboard {})
"view-box=\"0 0 100 20\""))))

;; Refactor the above test to use a let value for the response from calling monitor-dashboard
;; Also consider using the (app (mock/request :get "/")) call in the let and comparing the :body from the response.

0 comments on commit d2016c0

Please sign in to comment.