mirror of https://github.com/logseq/logseq
roam/json->edn test runs in clj
parent
06f7d6ddc1
commit
b9416ac989
4
deps.edn
4
deps.edn
|
@ -38,14 +38,14 @@
|
|||
org.clojure/tools.namespace {:mvn/version "0.2.11"}
|
||||
cider/cider-nrepl {:mvn/version "0.25.5"}}
|
||||
:main-opts ["-m" "shadow.cljs.devtools.cli"]}
|
||||
:test-cljs
|
||||
:test
|
||||
{:extra-paths ["src/test/"]
|
||||
:extra-deps {
|
||||
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-paths ["src/test/"]
|
||||
:extra-deps
|
||||
{cheshire/cheshire {:mvn/version "5.10.0"}
|
||||
com.cognitect/test-runner
|
||||
|
|
|
@ -120,12 +120,15 @@
|
|||
(apply str))))
|
||||
files)))
|
||||
|
||||
(defn json->edn
|
||||
[raw-string]
|
||||
#?(:cljs (-> raw-string js/JSON.parse bean/->clj)
|
||||
:clj (-> raw-string json/parse-string clojure.walk/keywordize-keys)))
|
||||
|
||||
(defrecord Roam []
|
||||
protocol/External
|
||||
(toMarkdownFiles [this content _config]
|
||||
#?(:cljs (let [data (bean/->clj (js/JSON.parse content))]
|
||||
(->files data))
|
||||
:clj (-> content json/parse-string ->files))))
|
||||
(->files content)))
|
||||
|
||||
(comment
|
||||
(defonce test-roam-json (frontend.db/get-file "same.json"))
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
(ns frontend.external.roam-test
|
||||
(:require #?(:clj [clojure.test :refer :all]
|
||||
:cljs [cljs.test :refer [is deftest]])
|
||||
;[frontend.external.roam :as roam]
|
||||
[frontend.external.roam :as roam]
|
||||
[frontend.external :refer [to-markdown-files]]))
|
||||
|
||||
(def minimal-json "
|
||||
|
@ -23,11 +23,15 @@
|
|||
\"edit-email\": \"adam@example.com\"}]
|
||||
")
|
||||
|
||||
(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 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))))))
|
Loading…
Reference in New Issue