Skip to content

Commit

Permalink
Start Testing Dashboard components
Browse files Browse the repository at this point in the history
Start writing tests for the dashboard components, testing the Hiccup structure
that should be returned.

Experimented in the REPL to check what the output should look like.
  • Loading branch information
practicalli-johnny committed Sep 22, 2018
1 parent 33e641f commit f7912e1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/status_monitor/handler.clj
Original file line number Diff line number Diff line change
Expand Up @@ -220,5 +220,10 @@
(rand-int (+ maximum-value 1))))


(mock-data 10.0)
#_(mock-data 10.0)
;; => "6.02"



#_(component-status-bar 50)
;; => [:svg {:view-box "0 0 100 20", :width 202, :height 22} [:rect {:x 1, :y 1, :width 50, :height 20, :rx 5, :ry 5, :stroke "black", :fill "orange"}]]
20 changes: 20 additions & 0 deletions test/status_monitor/handler_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,23 @@
(testing "not-found route"
(let [response (app (mock/request :get "/invalid"))]
(is (= (:status response) 404)))))


(deftest test-components
(testing "UI data generated by the dashboard components in Hiccup format"
(let [component-50-per-cent
[:svg
{:view-box "0 0 100 20"
:width 202
:height 22}
[:rect
{:x 1
:y 1
:width 50
:height 20
:rx 5
:ry 5
:stroke "black"
:fill "orange"}]]]
(is (= (component-status-bar 50)
component-50-per-cent)))))

0 comments on commit f7912e1

Please sign in to comment.