Skip to content

Instantly share code, notes, and snippets.

@ckirkendall
Created March 9, 2012 23:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ckirkendall/2009301 to your computer and use it in GitHub Desktop.
Save ckirkendall/2009301 to your computer and use it in GitHub Desktop.
(ns goog-test.core
(:require [goog.testing.jsunit :as unit]
[goog.testing :as gt]
[goog.testing.TestCase :as tc])
(:use [midje.cljs.core :only [run-test]])
(:use-macros [midje.cljs.semi-sweet :only [expect fact run-tests]]
[midje.cljs.sweet :only [fact provided]]))
(defn world [] "world")
(defn hello [] (str "hello " (world)))
(defn hello2 [] (str "hello " (world) " hello " (world)))
(expect "testing1"
(hello2) => "hello test hello test"
(fake (goog-test.core/world) => "test" :times 2))
(fact "testing2"
(hello2) => "hello test hello test"
(provided (goog-test.core/world) => "test" :times 2))
(fact "testing3"
(hello2) => "hello test hello test"
(provided (goog-test.core/world) => "test"))
(fact "testing3"
(hello) => "hello test"
(provided (goog-test.core/world) => "test" :times 2))
(set! (.-onload js/window) run-test)
Midge ClojureScript Tests [FAILED]
/home/ckirkendall/Development/clojure/goog-test/resources/public/test.html
4 of 4 tests run in 16ms.
2 passed, 2 failed.
4 ms/test. 2 files loaded.
.
18:27:59.235 Start
18:27:59.240 testing1 : PASSED
18:27:59.242 testing2 : PASSED
18:27:59.245 testing3 : FAILED (run individually)
18:27:59.246 ERROR in testing3
Test runner not initialized with a test case. Original exception: Unexpected call to world().
> (unknown)
> [object Object].logTestFailure at file:///home/ckirkendall/Development/clojure/goog-test/resources/public/js/main.js:4536:11
> [object Function].$recordAndThrow at file:///home/ckirkendall/Development/clojure/goog-test/resources/public/js/main.js:3939:32
> [object Function].$throwException at file:///home/ckirkendall/Development/clojure/goog-test/resources/public/js/main.js:3931:8
> [object Function].$throwCallException at file:///home/ckirkendall/Development/clojure/goog-test/resources/public/js/main.js:3983:8
> [object Function].$recordCall at file:///home/ckirkendall/Development/clojure/goog-test/resources/public/js/main.js:3998:10
> [object Function].$mockMethod at file:///home/ckirkendall/Development/clojure/goog-test/resources/public/js/main.js:3867:19
> anonymous at file:///home/ckirkendall/Development/clojure/goog-test/resources/public/js/main.js:4044:27
> hello2 at file:///home/ckirkendall/Development/clojure/goog-test/resources/public/js/main.js:15140:110
18:27:59.247 testing3 : FAILED (run individually)
18:27:59.248 ERROR in testing3
Test runner not initialized with a test case. Original exception: Missing a call to world
Expected: 2 but was: 1
> (unknown)
> (unknown)
> [object Object].logTestFailure at file:///home/ckirkendall/Development/clojure/goog-test/resources/public/js/main.js:4536:11
> [object Function].$recordAndThrow at file:///home/ckirkendall/Development/clojure/goog-test/resources/public/js/main.js:3939:32
> [object Function].$throwException at file:///home/ckirkendall/Development/clojure/goog-test/resources/public/js/main.js:3931:8
> [object Function].$verify at file:///home/ckirkendall/Development/clojure/goog-test/resources/public/js/main.js:4026:12
18:27:59.248 Done
Run again without reloading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment