mirror of
https://github.com/penpot/penpot.git
synced 2025-08-03 07:38:35 +02:00
✨ Add serialization support for PathData
For transit and fressian
This commit is contained in:
parent
e62231cfed
commit
fac93e4ff8
2 changed files with 64 additions and 9 deletions
|
@ -6,9 +6,11 @@
|
|||
|
||||
(ns common-tests.types.shape-path-data-test
|
||||
(:require
|
||||
#?(:clj [app.common.fressian :as fres])
|
||||
[app.common.data :as d]
|
||||
[app.common.math :as mth]
|
||||
[app.common.pprint :as pp]
|
||||
[app.common.transit :as trans]
|
||||
[app.common.types.shape.path :as path]
|
||||
[clojure.test :as t]))
|
||||
|
||||
|
@ -57,3 +59,19 @@
|
|||
(mapv path/map->PathSegment))
|
||||
(vec pdata)))))
|
||||
|
||||
(t/deftest path-data-transit-roundtrip
|
||||
(let [pdata (path/path-data sample-content)
|
||||
result1 (trans/encode-str pdata)
|
||||
expected "[\"~#penpot/path-data\",\"~bAAEAAAAAAAAAAAAAAAAAAAAAAABD8AAARFHAAAACAAAAAAAAAAAAAAAAAAAAAAAAQ9uAAERIgAAAAwAAQ7gAAEQ4QABDmwAARCpAAEOEAABEHoAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==\"]"
|
||||
result2 (trans/decode-str result1)]
|
||||
|
||||
(t/is (= expected result1))
|
||||
(t/is (= pdata result2))))
|
||||
|
||||
#?(:clj
|
||||
(t/deftest path-data-fresian
|
||||
(let [pdata (path/path-data sample-content)
|
||||
result1 (fres/encode pdata)
|
||||
result2 (fres/decode result1)]
|
||||
(t/is (= pdata result2)))))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue