mirror of
https://github.com/penpot/penpot.git
synced 2026-07-03 12:55:04 +00:00
* ✨ Adds static dispatch safe stubs in tests * 🐛 Fix shapesColors metadata key to match ColorShapeInfo * 🐛 Fix CommentThread.remove rejecting the owner's own threads * 🐛 Fix page.removeCommentThread throwing on a spurious Promise * ✨ Implement ShapeBase.swapComponent in the plugin API * ✨ Expose File.revn in the plugin API * 🐛 Fix FileVersion.createdAt calling Luxon method on a js/Date * 🐛 Fix plugin font/typography application to text and ranges * 🐛 Default plugin overlay interaction position for non-manual types * 🐛 Fix plugin interaction setters passing an id-only shape * 🐛 Fix grid addColumnAtIndex rejecting valid track types * 🐛 Expose libraryId on library color/typography/component proxies * ✨ Implement LibraryTypography.setFont in the plugin API * 🐛 Fix typography.applyToTextRange reading unexposed range bounds * 🐛 Fix utils.geometry.center argument mismatch * 🐛 Fix localStorage.removeItem calling getItem * 🐛 Fix shape backgroundBlur proxy key casing * 🐛 Report boolean shape type as 'boolean' in the plugin API * 🐛 Return the resulting paths from plugin flatten * 🐛 Make plugin z-order methods act on the target shape * 🐛 Make is-variant-container? return a boolean * ✨ Implement Group.isMask in the plugin API * 🐛 Return a shape proxy from TextRange.shape * 🐛 Return the duplicated set from TokenSet.duplicate * 🐛 Fix theme addSet/removeSet reading set name with a keyword * 🐛 Accept string fontFamilies token value in the plugin API * 🐛 Fix combineAsVariants ignoring the passed component ids * 🐛 Fix board removeRulerGuide ignoring its argument * 🐛 Fix board guides setter schema and parser * 🐛 Avoid 0-byte allocation when syncing empty grid tracks * 🐛 Validate grid track indices in the plugin API * 🐛 Return null for empty input in group() and centerShapes() * 🐛 Return TokenTypographyValue[] from a typography token's resolvedValue * 🐛 Return TokenShadowValue[] from a shadow token's resolvedValue * 🐛 Return string[] from a fontFamilies token's resolvedValue * 🐛 Clear mutually-exclusive reps when setting LibraryColor gradient/image * 🐛 Add readonly tags to types, deprecate Image type * 📚 Update plugins changelog
55 lines
2.1 KiB
Clojure
55 lines
2.1 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 Sucursal en España SL
|
|
|
|
(ns frontend-tests.plugins.format-test
|
|
(:require
|
|
[app.plugins.format :as format]
|
|
[cljs.test :as t :include-macros true]))
|
|
|
|
(t/deftest test-format-array-always-returns-array
|
|
(t/testing "nil collection returns an empty array"
|
|
(let [result (format/format-array identity nil)]
|
|
(t/is (array? result))
|
|
(t/is (= 0 (.-length result)))))
|
|
|
|
(t/testing "empty collection returns an empty array"
|
|
(let [result (format/format-array identity [])]
|
|
(t/is (array? result))
|
|
(t/is (= 0 (.-length result)))))
|
|
|
|
(t/testing "non-empty collection maps each item"
|
|
(let [result (format/format-array inc [1 2 3])]
|
|
(t/is (array? result))
|
|
(t/is (= [2 3 4] (vec result)))))
|
|
|
|
(t/testing "items dropped by format-fn (nil) are removed"
|
|
(let [result (format/format-array #(when (odd? %) %) [1 2 3 4])]
|
|
(t/is (= [1 3] (vec result))))))
|
|
|
|
(t/deftest test-array-wrappers-return-empty-array-on-nil
|
|
;; Each wrapper backs a non-nullable array-typed Plugin API property and
|
|
;; must return an empty array (never nil) when the source collection is nil.
|
|
(t/are [result] (and (array? result) (= 0 (.-length result)))
|
|
(format/format-shadows nil)
|
|
(format/format-exports nil)
|
|
(format/format-frame-guides nil)
|
|
(format/format-tracks nil)
|
|
(format/format-path-content nil)))
|
|
|
|
(t/deftest test-format-color-result-uses-shapes-info-key
|
|
(let [shape-id (random-uuid)
|
|
result (format/format-color-result
|
|
[{:color "#fabada"}
|
|
[{:prop :fill :shape-id shape-id :index 0}]])
|
|
info (aget result "shapesInfo")]
|
|
(t/is (array? info))
|
|
(t/is (nil? (aget result "shapesColors")))
|
|
(t/is (= "fill" (aget (aget info 0) "property")))
|
|
(t/is (= (str shape-id) (aget (aget info 0) "shapeId")))))
|
|
|
|
(t/deftest test-shape-type-reports-boolean
|
|
(t/is (= "boolean" (format/shape-type :bool))))
|