-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Why: - Continuing the migration from SPA to SSR.
- Loading branch information
Showing
4 changed files
with
112 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
;; Copyright © 2015-2024 Esko Luontola | ||
;; This software is released under the Apache License 2.0. | ||
;; The license text is at http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
(ns territory-bro.ui.printout-templates-test | ||
(:require [clojure.string :as str] | ||
[clojure.test :refer :all] | ||
[territory-bro.ui.html :as html] | ||
[territory-bro.ui.printout-templates :as printout-templates]) | ||
(:import (java.time LocalDate) | ||
(java.util UUID))) | ||
|
||
(use-fixtures :once (fn [f] | ||
(binding [html/*page-path* "page-url"] | ||
(f)))) | ||
|
||
(deftest print-date-notice-test | ||
(is (= "Printed 2000-12-31 with TerritoryBro.com [content]" | ||
(-> (printout-templates/print-date-notice (LocalDate/of 2000 12 31) "[content]") | ||
html/visible-text)))) | ||
|
||
(def territory-printout-model | ||
{:territory {:id (UUID. 0 1) | ||
:number "123" | ||
:addresses "The Addresses" | ||
:region "The Region" | ||
:location "MULTIPOLYGON(territory)"} | ||
:congregation-boundary "MULTIPOLYGON(congregation boundary)" | ||
:enclosing-region "MULTIPOLYGON(region)" | ||
:enclosing-minimap-viewport "POLYGON(minimap viewport)" | ||
:map-raster "osmhd" | ||
:print-date (LocalDate/of 2024 7 10)}) | ||
|
||
(def region-printout-model) ; TODO | ||
|
||
(deftest territory-card-test | ||
(testing "no data" | ||
(is (= (html/normalize-whitespace | ||
"Territory Map Card | ||
Printed with TerritoryBro.com | ||
Please keep this card in the envelope. Do not soil, mark or bend it. | ||
Each time the territory is covered, please inform the brother who cares for the territory files.") | ||
(-> (printout-templates/territory-card nil) | ||
html/visible-text)))) | ||
|
||
(testing "full data" | ||
(let [html (printout-templates/territory-card territory-printout-model)] | ||
(is (= (html/normalize-whitespace | ||
"Territory Map Card | ||
The Region | ||
123 | ||
Printed 2024-07-10 with TerritoryBro.com | ||
The Addresses | ||
Please keep this card in the envelope. Do not soil, mark or bend it. | ||
Each time the territory is covered, please inform the brother who cares for the territory files.") | ||
(html/visible-text html))) | ||
(is (str/includes? html "territory=\"MULTIPOLYGON(territory)\"")) | ||
(is (str/includes? html "congregation-boundary=\"MULTIPOLYGON(congregation boundary)\"")) | ||
(is (str/includes? html "enclosing-region=\"MULTIPOLYGON(region)\"")) | ||
(is (str/includes? html "enclosing-minimap-viewport=\"POLYGON(minimap viewport)\"")) | ||
(is (str/includes? html "map-raster=\"osmhd\"")) | ||
(is (str/includes? html "hx-get=\"page-url/qr-code/00000000-0000-0000-0000-000000000001\""))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters