-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix browse in
build-static-app!
on windows (#39)
Fixes #38. Co-authored-by: ikappaki <ikappaki@users.noreply.github.com> Co-authored-by: Martin Kavalar <mk@katercalling.com>
- Loading branch information
1 parent
68f6545
commit 415a5eb
Showing
3 changed files
with
37 additions
and
5 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,24 @@ | ||
(ns nextjournal.clerk-test | ||
(:require [babashka.fs :as fs] | ||
[clojure.java.browse :as browse] | ||
[clojure.string :as str] | ||
[clojure.test :refer :all] | ||
[nextjournal.clerk :as clerk]) | ||
(:import (java.io File))) | ||
|
||
(deftest url-canonicalize | ||
(testing "canonicalization of file components into url components" | ||
(let [dice (str/join (File/separator) ["notebooks" "dice.clj"])] | ||
(is (= (#'clerk/path-to-url-canonicalize dice) (str/replace dice (File/separator) "/")))))) | ||
|
||
(deftest static-app | ||
(let [url* (volatile! nil)] | ||
(with-redefs [clojure.java.browse/browse-url (fn [path] | ||
(vreset! url* path))] | ||
(testing "browser receives canonical url in this system arch" | ||
(fs/with-temp-dir [temp {}] | ||
(let [expected (-> (str/join (java.io.File/separator) [(.toString temp) "index.html"]) | ||
(str/replace (java.io.File/separator) "/"))] | ||
(clerk/build-static-app! {:paths ["notebooks/hello.clj"] | ||
:out-path temp}) | ||
(is (= expected @url*)))))))) |