Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
:url "http://keminglabs.com/c2/"
:license {:name "BSD" :url "http://www.opensource.org/licenses/BSD-3-Clause"}

:dependencies [[org.clojure/clojure "1.4.0"]
:dependencies [[org.clojure/clojure "1.5.1"]
[org.clojure/clojurescript "0.0-2227"]
[org.clojure/core.match "0.2.0-alpha12"
:exclusions [org.clojure/core.logic]]
[clj-iterate "0.96"]
Expand All @@ -18,7 +19,7 @@
:min-lein-version "2.0.0"

:plugins [[com.keminglabs/cljx "0.2.1"]
[lein-cljsbuild "0.3.1"]
[lein-cljsbuild "1.0.3"]
[lein-midje "3.0.0"]
[lein-marginalia "0.7.0"]]

Expand Down
8 changes: 4 additions & 4 deletions test/integration/cljs/choropleth_test.cljs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns c2.choropleth-test
(:use-macros [c2.util :only [p pp profile]])
(:use [c2.core :only [unify! style]]
(:use-macros [c2.util :only [p pp profile bind!]])
(:use [c2.core :only [unify]]
[c2.maths :only [extent floor]]
[c2.geo.core :only [geo->svg]]
[c2.geo.projection :only [albers-usa]]
Expand All @@ -25,11 +25,11 @@
:viewBox "0 0 950 500"}])
$states (dom/append! $svg [:g.states])]

(unify! $states data
(bind! $states (unify data
(fn [[state-name val]]
[:path.state {:d (geo->svg (get states state-name)
:projection proj)
:stroke "black"
:fill (color-scale val)}]))
:fill (color-scale val)}])))

(dom/remove! $svg)))
22 changes: 11 additions & 11 deletions test/integration/cljs/core_test.cljs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(ns c2.core-test
(:use-macros [c2.util :only [p pp profile]])
(:use-macros [c2.util :only [p pp profile bind!]])
(:require [c2.svg :as svg])
(:use [c2.core :only [unify!]]
(:use [c2.core :only [unify]]
[c2.dom :only [attr children]]))

(set! *print-fn* #(.log js/console %))
Expand All @@ -24,15 +24,15 @@
mapping (fn [d] [:span {:x d} (str d)])]

(profile (str "ENTER single tag with " n " data")
(unify! container (range n) mapping))
(bind! container (unify (range n) mapping)))
(let [children (children container)
fel (first children)]
(assert (= n (count children)))
(assert (= "span" (.toLowerCase (.-nodeName fel))))
(assert (= "0" (:x (attr fel)))))

(profile (str "UPDATE single tag, reversing order")
(unify! container (reverse (range n)) mapping))
(bind! container (unify (reverse (range n)) mapping)))
(let [children (children container)
fel (first children)]
(assert (= n (count children)))
Expand All @@ -41,12 +41,12 @@


(profile (str "UPDATE single tag with new datum")
(unify! container (range (inc n)) mapping))
(bind! container (unify (range (inc n)) mapping)))
(assert (= (inc n) (count (children container))))


(profile (str "REMOVE " (/ n 2) " single tags")
(unify! container (range (/ n 2)) mapping))
(bind! container (unify (range (/ n 2)) mapping)))
(assert (= (/ n 2) (count (children container)))))


Expand All @@ -60,7 +60,7 @@
!ds (atom (range n))]

(profile (str "ENTER single tag with " n " data")
(unify! container !ds mapping))
(bind! container (unify @!ds mapping)))
(let [children (children container)
fel (first children)]
(assert (= n (count children)))
Expand All @@ -86,13 +86,13 @@
mapping (fn [d idx] [:div {:val (:val d)}
[:span (str (:id d))]])]
(profile "ENTER node hiearchy"
(unify! container data mapping
:key-fn :id))
(bind! container (unify data mapping
:key-fn #(:id %))))
(assert (= 100 (count (children container))))

(profile "UPDATE/EXIT node hiearchy"
(unify! container (take 10 new-data) mapping
:key-fn :id))
(bind! container (unify (take 10 new-data) mapping
:key-fn #(:id %))))

(assert (= 10 (count (children container))))
(assert (= (:val (first new-data))
Expand Down
8 changes: 4 additions & 4 deletions test/integration/cljs/dom_test.cljs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns c2.dom-test
(:use-macros [c2.util :only [p pp profile]])
(:use [c2.dom :only [attr build-dom-elem merge! append! text]]))
(:use [c2.dom :only [attr ->dom append! text]]))

(set! *print-fn* #(.log js/console %))

Expand All @@ -25,12 +25,12 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;DOM Element creation from vectors
(assert (= "<p><span>hello</span><i>0</i><i>1</i><i>2</i></p>"
(.-outerHTML (build-dom-elem [:p [:span "hello"]
(map #(vector :i %) (range 3))])))
(.-outerHTML (->dom [:p [:span "hello"]
(map #(vector :i %) (range 3))])))
"Literal and seq children.")

(assert (= "<span class=\"a b\"></span>"
(.-outerHTML (build-dom-elem [:span.a {:class "b"}])))
(.-outerHTML (->dom [:span.a {:class "b"}])))
"Class literal and in attr map")


Expand Down