mirror of
https://github.com/penpot/penpot.git
synced 2026-05-04 15:49:34 +00:00
* 🐛 Fix MCP media uploads and SVG data URI image parsing Signed-off-by: Clayton <claytonlin1110@gmail.com> * 🐛 Fix lint Signed-off-by: Clayton <claytonlin1110@gmail.com> * 🐛 Fix test Signed-off-by: Clayton <claytonlin1110@gmail.com> --------- Signed-off-by: Clayton <claytonlin1110@gmail.com>
35 lines
1.3 KiB
Clojure
35 lines
1.3 KiB
Clojure
;; This Source Code Form is subject to the terms of the Mozilla Public
|
|
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
;;
|
|
;; Copyright (c) KALEIDOS INC
|
|
|
|
(ns frontend-tests.util-webapi-test
|
|
(:require
|
|
[app.util.webapi :as wapi]
|
|
[cljs.test :as t :include-macros true]))
|
|
|
|
(t/deftest data-uri->blob-supports-base64
|
|
(t/async done
|
|
(let [blob (wapi/data-uri->blob "data:text/plain;base64,SGVsbG8=")]
|
|
(-> (.text blob)
|
|
(.then (fn [text]
|
|
(t/is (= "text/plain" (.-type blob)))
|
|
(t/is (= "Hello" text))
|
|
(done)))
|
|
(.catch (fn [err]
|
|
(t/is false (str "unexpected error: " err))
|
|
(done)))))))
|
|
|
|
(t/deftest data-uri->blob-supports-utf8-data
|
|
(t/async done
|
|
(let [blob (wapi/data-uri->blob "data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3C%2Fsvg%3E")]
|
|
(-> (.text blob)
|
|
(.then (fn [text]
|
|
(t/is (= "image/svg+xml" (.-type blob)))
|
|
(t/is (= "<svg xmlns=\"http://www.w3.org/2000/svg\"></svg>" text))
|
|
(done)))
|
|
(.catch (fn [err]
|
|
(t/is false (str "unexpected error: " err))
|
|
(done)))))))
|