Skip to content

Support comparing native JS objects in CLJS #24

@bshepherdson

Description

@bshepherdson

Two JS objects or arrays with =? contents should be =?.

Deep comparison on JS objects is intractable, but we can support the obvious cases of vanilla objects and arrays. If the constructor on either side is something else (like a custom class) then it can be always false.

;; I want to write this.
(deftest slick-test
  (is (=? #js {:abc 7, :xyz {:some "Clojure map"}}
          (a-function 7))))

;; Instead I have to write this.
(deftest clunky-test
  (let [js-blob (a-function 7)]
    (is (=? 7 (.-abc js-blob)))
    (is (=? {:some "Clojure map"} (.-xyz js-blob)))))

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions