Permalink
Browse files

add cljs view test that uses an external :require

  • Loading branch information...
1 parent 67733f2 commit db4cc8d6cd7673c04f1e40d94642f04acc96b0e9 @cemerick cemerick committed May 7, 2012
Showing with 24 additions and 0 deletions.
  1. +15 −0 test/clutch/test/views.clj
  2. +9 −0 test/clutch/test/views/util.cljs
View
@@ -182,4 +182,19 @@
(js/emit (view-key doc x) (inc x))))]}}))
(is (= cljs-view-result
(get-view "namespaced-cljs-views" :enumeration))))
+
+ (defdbtest cljs-require
+ (bulk-update [{:_id "x" :count 2}
+ {:_id "y" :count 3}])
+ (save-view "cljs-views-require"
+ (view-server-fns {:language :cljs
+ :main 'inline.namespace.couchview/main}
+ {:enumeration {:map [(ns inline.namespace.couchview
+ (:require [clutch.test.views.util :as util]))
+ (defn ^:export main
+ [doc]
+ (doseq [key (util/enumerate-count doc)]
+ (js/emit (to-array key) true)))]}}))
+ (is (= (map #(assoc % :value true) cljs-view-result)
+ (get-view "cljs-views-require" :enumeration)))))))
@@ -0,0 +1,9 @@
+(ns clutch.test.views.util)
+
+(defn enumerate-count
+ "A trivial fn that is used by one of the ClojureScript view tests to ensure that
+ requires and such work as expected."
+ [doc]
+ (->> (aget doc "count")
+ range
+ (map vector (repeat (aget doc "_id")))))

0 comments on commit db4cc8d

Please sign in to comment.