🐛 Count id and type in the wasm shape proxy (#12793)

The proxy counted one entry fewer than it yields, so it was never equal to a
plain map with the same entries. Count both fields and test it.
This commit is contained in:
Elena Torró 2026-11-04 13:01:05 +01:00 committed by GitHub
parent 2573908315
commit 8d7e275b6b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 27 additions and 1 deletions

View File

@ -77,7 +77,7 @@
c/ICounted
(-count [_]
(+ 1 (count delegate)))
(+ 2 (count delegate)))
c/IKVReduce
(-kv-reduce [_ f init]

View File

@ -0,0 +1,24 @@
;; 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 SUBSIDIARY SL
(ns frontend-tests.render-wasm.shape-proxy-test
(:require
[app.common.uuid :as uuid]
[app.render-wasm.shape :as wasm.shape]
[cljs.test :as t :include-macros true]))
(def ^:private attrs
{:id (uuid/next) :type :rect :name "Rect" :x 10 :y 20})
(t/deftest count-includes-id-and-type
(let [shape (wasm.shape/create-shape attrs)]
(t/is (= (count attrs) (count shape)))
(t/is (= (count shape) (count (seq shape))))))
(t/deftest equals-plain-map-with-same-entries
(let [shape (wasm.shape/create-shape attrs)]
(t/is (= shape attrs))
(t/is (= attrs shape))))

View File

@ -94,6 +94,7 @@
[frontend-tests.render-dimensions-test]
[frontend-tests.render-wasm.process-objects-test]
[frontend-tests.render-wasm.serialization-test]
[frontend-tests.render-wasm.shape-proxy-test]
[frontend-tests.render-wasm.text-editor-apply-styles-test]
[frontend-tests.render-wasm.text-editor-caret-color-test]
[frontend-tests.render-wasm.text-editor-content-range-test]
@ -273,6 +274,7 @@
'frontend-tests.plugins.value-objects-test
'frontend-tests.render-wasm.process-objects-test
'frontend-tests.render-wasm.serialization-test
'frontend-tests.render-wasm.shape-proxy-test
'frontend-tests.render-wasm.text-editor-apply-styles-test
'frontend-tests.render-wasm.text-editor-caret-color-test
'frontend-tests.render-wasm.text-editor-content-range-test