   (:require [overcode.introvert :as introvert]
             [cemerick.cljs.test :as test])
   (:require-macros [cemerick.cljs.test :refer (is deftest)]))
+
+(defn is=
+  "Compares JS values using deep=."
+  ([val1 val2] (is= val1 val2 nil))
+  ([val1 val2 msg]
+     (is (introvert/deep= val1 val2) msg)))
 
 ;;***************************************************************************
 ;; Identities
 ;;***************************************************************************
 (let [identity->js
       (fn identity->js [v]
-        (is (introvert/->js v) v))]
+        (is= (introvert/->js v) v))]
 
   (deftest str->js
     (identity->js "hello!"))

        b-js (array 9 a-js)]

    (swap! a conj b)
    (.push a-js b)

    (is (introvert/->js b)
        b-js)))

(deftest circular-map->js
  (let [a (atom {:1 1})

(let [in  {"one" 1 "two" 2 "three" "three"}
      out (js-obj "one" 1 "two" 2 "three" "three")]
  (deftest PersistentArrayMap->js
    (is= (introvert/->js in)
         out))

  (deftest PersistentHashMap->js
    (is= (introvert/->js (into (hash-map) in))
         out))

  (deftest atomic-map->js
    (is= (introvert/->js (atom in))
         out)))


;;***************************************************************************
;; Recursion
;;***************************************************************************
(deftest RecursiveSeq->js
  (is= (introvert/->js (seq [1 "2" :three [:four 5]]))
       (array 1 "2" "three" (array "four" 5))))

(deftest RecursiveMap->js
  (is= (introvert/->js {:one 1 :two :two :three {:a "A"}})
       (js-obj "one" 1 "two" "two" "three" (js-obj "a" "A"))))


;;***************************************************************************
