Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support comparing native JS objects in CLJS #24

Open
bshepherdson opened this issue Apr 10, 2024 · 0 comments
Open

Support comparing native JS objects in CLJS #24

bshepherdson opened this issue Apr 10, 2024 · 0 comments
Assignees

Comments

@bshepherdson
Copy link

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)))))
@bshepherdson bshepherdson self-assigned this Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant