Skip to content

Commit

Permalink
[#38] Add ts complex test fixture & assert
Browse files Browse the repository at this point in the history
Co-authored-by: kenichsberg <kn1017356@gmail.com>
  • Loading branch information
KGOH and kenichsberg committed Jan 20, 2023
1 parent d06e7f0 commit 54dc3a8
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions test/zen/schema_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
(update vtx ::ts conj s)
vtx))))

(sut/register-compile-key-interpreter!
[:every ::ts]
(fn [_ ztx every]
(fn [vtx data opts]
(update vtx ::ts conj "Array < "))))

(sut/register-compile-key-interpreter!
[:type ::ts]
(fn [_ ztx ks]
Expand All @@ -42,7 +48,7 @@
vtx))))


(t/deftest custom-interpreter-test
(t/deftest ^:kaocha/pending custom-interpreter-test
(t/testing "typescript type generation"
(def ztx (zen.core/new-context {}))

Expand All @@ -55,25 +61,28 @@
:keys {:id {:type zen/string}
:email {:type zen/string
#_#_:regex "@"}
#_#_:name {:type zen/vector
:every {:type zen/map
:keys {:given {:type zen/vector
:every {:type zen/string}}
:family {:type zen/string}}}}}}})
:name {:type zen/vector
:every {:type zen/map
:keys {:given {:type zen/vector
:every {:type zen/string}}
:family {:type zen/string}}}}}}})

(zen.core/load-ns ztx my-structs-ns)

(def ts-typedef-assert
(str "type User = {"
"id: string;"
"email: string;"
"}"))
"name: Array < {"
"given: Array < string >;"
"family: string;"
"}>}"))

(def r
(sut/apply-schema ztx
{::ts []}
(zen.core/get-symbol ztx 'zen/schema)
(zen.core/get-symbol ztx 'my-sturcts/User)
{:interpreters [#_:zen.v2-validation/validate ::ts]}))
{:interpreters [::ts]}))

(t/is (= ts-typedef-assert (str/join "" (distinct (::ts r)))))))

0 comments on commit 54dc3a8

Please sign in to comment.