-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
roam_test.cljc
36 lines (33 loc) · 1.22 KB
/
roam_test.cljc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
(ns frontend.external.roam-test
(:require #?(:clj [clojure.test :refer :all]
:cljs [cljs.test :refer [is deftest]])
[frontend.external.roam :as roam]
[frontend.external :refer [to-markdown-files]]))
(def minimal-json "
[
{
\"create-email\": \"adam@example.com\",
\"create-time\": 1610708403162,
\"title\": \"Export JSON\",
\"children\": [
{
\"string\": \"Hello, world!\",
\"create-email\": \"adam@example.com\",
\"create-time\": 1610708405787,
\"uid\": \"7c5um7hSz\",
\"edit-time\": 1610708415484,
\"edit-email\": \"adam@example.com\"}
],
\"edit-time\": 1610708403169,
\"edit-email\": \"adam@example.com\"}]
")
(deftest json->edn-test
(is (= [1 {:foo 42, :bar "baz"} 3] (roam/json->edn "[1, {\"foo\": 42, \"bar\": \"baz\"}, 3]"))))
(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)))))