Browse Source

final touches on dual platform testing of Raom import

Adam Schmideg 5 years ago
parent
commit
a9df8deaae
4 changed files with 28 additions and 11 deletions
  1. 14 0
      README.md
  2. 5 1
      deps.edn
  3. 1 1
      src/main/frontend/external/roam.cljc
  4. 8 9
      src/test/frontend/external/roam_test.cljc

+ 14 - 0
README.md

@@ -89,6 +89,20 @@ Open <http://localhost:3001>.
 yarn release
 ```
 
+### 5. Run tests
+
+Run ClojureScript tests
+```bash
+yarn
+yarn cljs:test
+node static/tests.js
+```
+
+Run Clojure tests. (Note: `.cljc` files may be tested both by ClojureScript, and Clojure.)
+```bash
+clj -Mtest-clj
+```
+
 ## Alternative: Docker based development environment
 
 ### 1. Fetch sources

+ 5 - 1
deps.edn

@@ -1,6 +1,7 @@
 {:paths ["src/main"]
  :deps
  {org.clojure/clojure         {:mvn/version "1.10.0"}
+  cheshire/cheshire {:mvn/version "5.10.0"}
   rum/rum                     {:mvn/version "0.12.3"}
   ;; rum                         {:local/root "/home/tienson/codes/source/clj/rum"}
   ;; persistent-sorted-set       {:mvn/version "0.1.2"}
@@ -44,11 +45,14 @@
                           org.clojure/clojurescript {:mvn/version "1.10.764"}
                           org.clojure/test.check {:mvn/version "RELEASE"}}
             :main-opts   ["-m" "shadow.cljs.devtools.cli"]}
+
            :test-clj
            {:extra-paths ["src/test/"]
             :extra-deps
-            {cheshire/cheshire {:mvn/version "5.10.0"}
+            {
              com.cognitect/test-runner
              {:git/url "https://github.com/cognitect-labs/test-runner",
               :sha "76568540e7f40268ad2b646110f237a60295fa3c"}},
             :main-opts ["-m" "cognitect.test-runner" "-d" "src/test"]}}}
+
+

+ 1 - 1
src/main/frontend/external/roam.cljc

@@ -128,7 +128,7 @@
 (defrecord Roam []
   protocol/External
   (toMarkdownFiles [this content _config]
-    (->files content)))
+    (-> content json->edn ->files)))
 
 (comment
   (defonce test-roam-json (frontend.db/get-file "same.json"))

+ 8 - 9
src/test/frontend/external/roam_test.cljc

@@ -26,12 +26,11 @@
 (deftest json->edn-test
   (is (= [1 {:foo 42, :bar "baz"} 3] (roam/json->edn "[1, {\"foo\": 42, \"bar\": \"baz\"}, 3]"))))
 
-(comment
-  (deftest roam-import-test
-    (let [got (to-markdown-files :roam minimal-json {})
-          md (first got)]
-      (is (= 1 (count got)))
-      (is (= "Export JSON" (:title md)))
-      (is (:created-at md))
-      (is (:last-modified-at md))
-      (is (= "---\ntitle: Export JSON\n---\n\n## Hello, world!\n" (:text md))))))
+(deftest roam-import-test
+  (let [got (to-markdown-files :roam minimal-json {})
+        md (first got)]
+    (is (= 1 (count got)))
+    (is (= "Export JSON" (:title md)))
+    (is (:created-at md))
+    (is (:last-modified-at md))
+    (is (= "---\ntitle: Export JSON\n---\n\n## Hello, world!\n" (:text md)))))