* They're now run with Karma * The React library is now downloaded and used locally * The module ttfe.core now has an "init" function that must be called from index.html, to avoid that the tests choke when they can't "paint" the pagemaster
@@ -3,3 +3,5 @@ | |||
target/ | |||
out/ | |||
ttfe.js | |||
node_modules/ | |||
karma-test.js |
@@ -0,0 +1,14 @@ | |||
var config = exports; | |||
config["Browser Tests"] = { | |||
environment: "browser", | |||
sources: [], | |||
tests: ["resources/js/my_cljs_project_browser_test.js", | |||
"resources/js/my_cljs_project_browser_optimized_test.js"] | |||
}; | |||
config["Node Tests"] = { | |||
environment: "node", | |||
sources: [], | |||
tests: ["resources/js/my_cljs_project_node_test.js"] | |||
}; |
@@ -76,5 +76,6 @@ | |||
<script src="out/goog/base.js" type="text/javascript"></script> | |||
<script src="ttfe.js" type="text/javascript"></script> | |||
<script type="text/javascript">goog.require("ttfe.core");</script> | |||
<script type="text/javascript">ttfe.core.init();</script> | |||
</body> | |||
</html> |
@@ -0,0 +1,63 @@ | |||
// Karma configuration | |||
// Generated on Thu Apr 03 2014 01:40:36 GMT+0200 (CEST) | |||
module.exports = function(config) { | |||
config.set({ | |||
// base path that will be used to resolve all patterns (eg. files, exclude) | |||
basePath: '', | |||
// frameworks to use | |||
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter | |||
frameworks: ['jasmine'], | |||
// list of files / patterns to load in the browser | |||
files: [ | |||
'react-0.9.0.js', | |||
'karma-test.js' | |||
], | |||
// list of files to exclude | |||
exclude: [], | |||
// preprocess matching files before serving them to the browser | |||
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor | |||
preprocessors: {}, | |||
// test results reporter to use | |||
// possible values: 'dots', 'progress' | |||
// available reporters: https://npmjs.org/browse/keyword/karma-reporter | |||
reporters: ['progress'], | |||
// web server port | |||
port: 9876, | |||
// enable / disable colors in the output (reporters and logs) | |||
colors: true, | |||
// level of logging | |||
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG | |||
logLevel: config.LOG_INFO, | |||
// enable / disable watching file and executing tests whenever any file changes | |||
autoWatch: false, | |||
// start these browsers | |||
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher | |||
browsers: ['Chrome'], | |||
// Continuous Integration mode | |||
// if true, Karma captures browsers, runs the tests and exits | |||
singleRun: true | |||
}); | |||
}; |
@@ -4,7 +4,8 @@ | |||
:dependencies [[org.clojure/clojure "1.5.1"] | |||
[org.clojure/clojurescript "0.0-2156"] | |||
[org.clojure/core.async "0.1.267.0-0d7780-alpha"] | |||
[om "0.5.0"]] | |||
[om "0.5.0"] | |||
[im.chit/purnam "0.4.3"]] | |||
:plugins [[lein-cljsbuild "1.0.2"]] | |||
@@ -17,4 +18,10 @@ | |||
:output-to "ttfe.js" | |||
:output-dir "out" | |||
:optimizations :none | |||
:source-map true}}]}) | |||
:source-map true}} | |||
{:id "karma-test" | |||
:source-paths ["src" "test"] | |||
:compiler {:pretty-print true | |||
:externs ["lib/react-0.9.0.min.js"] | |||
:output-to "karma-test.js" | |||
:optimizations :whitespace}}]}) |
@@ -36,6 +36,7 @@ | |||
#js {:id "tiles" :className "tile-container"} | |||
cell-divs))))) | |||
(om/root tiles-view | |||
app-state | |||
{:target (. js/document (getElementById "tiles"))}) | |||
(defn init [] | |||
(om/root tiles-view | |||
app-state | |||
{:target (. js/document (getElementById "tiles"))})) |
@@ -1,100 +1,101 @@ | |||
(ns ttfe.core-test | |||
(:require [ttfe.core :refer :all] | |||
[clojure.test :refer :all])) | |||
(:require [ttfe.board :refer [move-right move-left move-up move-down]] | |||
[purnam.test :refer [toSatisfy]]) | |||
(:use-macros [purnam.test :only [describe it is is-not]])) | |||
(deftest test-move-right | |||
(testing "Can move a single number" | |||
(is (= (move-right [[nil nil 4 nil] | |||
(describe test-move-right | |||
(it "Can move a single number" | |||
(is (move-right [[nil nil 4 nil] | |||
[nil nil nil nil] | |||
[nil nil nil nil] | |||
[nil nil nil nil]]) | |||
[[nil nil nil 4 ] | |||
[nil nil nil nil] | |||
[nil nil nil nil] | |||
[nil nil nil nil]]))) | |||
[nil nil nil nil]])) | |||
(testing "Can move two numbers in different rows" | |||
(is (= (move-right [[nil nil 4 nil] | |||
(it "Can move two numbers in different rows" | |||
(is (move-right [[nil nil 4 nil] | |||
[nil nil nil nil] | |||
[nil 2 nil nil] | |||
[nil nil nil nil]]) | |||
[[nil nil nil 4 ] | |||
[nil nil nil nil] | |||
[nil nil nil 2 ] | |||
[nil nil nil nil]]))) | |||
[nil nil nil nil]])) | |||
(testing "Can combine simple numbers" | |||
(is (= (move-right [[nil nil 2 2 ] | |||
(it "Can combine simple numbers" | |||
(is (move-right [[nil nil 2 2 ] | |||
[nil nil nil nil] | |||
[nil nil nil nil] | |||
[nil nil nil nil]]) | |||
[[nil nil nil 4 ] | |||
[nil nil nil nil] | |||
[nil nil nil nil] | |||
[nil nil nil nil]]))) | |||
[nil nil nil nil]])) | |||
(testing "Can combine chains of numbers" | |||
(is (= (move-right [[ 4 4 2 2 ] | |||
(it "Can combine chains of numbers" | |||
(is (move-right [[ 4 4 2 2 ] | |||
[nil nil nil nil] | |||
[nil nil nil nil] | |||
[nil nil nil nil]]) | |||
[[nil nil 8 4 ] | |||
[nil nil nil nil] | |||
[nil nil nil nil] | |||
[nil nil nil nil]]))) | |||
[nil nil nil nil]])) | |||
(testing "Can combine numbers that aren't adjacent" | |||
(is (= (move-right [[nil 2 nil 2 ] | |||
(it "Can combine numbers that aren't adjacent" | |||
(is (move-right [[nil 2 nil 2 ] | |||
[nil nil nil nil] | |||
[nil nil nil nil] | |||
[nil nil nil nil]]) | |||
[[nil nil nil 4 ] | |||
[nil nil nil nil] | |||
[nil nil nil nil] | |||
[nil nil nil nil]]))) | |||
[nil nil nil nil]])) | |||
(testing "Number combination starts the right way" | |||
(is (= (move-right [[ 2 2 nil 2 ] | |||
(it "Number combination starts the right way" | |||
(is (move-right [[ 2 2 nil 2 ] | |||
[nil nil nil nil] | |||
[nil nil nil nil] | |||
[nil nil nil nil]]) | |||
[[nil nil 2 4 ] | |||
[nil nil nil nil] | |||
[nil nil nil nil] | |||
[nil nil nil nil]])))) | |||
[nil nil nil nil]]))) | |||
(deftest test-move-left | |||
(testing "Can move two numbers in different rows" | |||
(is (= (move-left [[nil nil 4 nil] | |||
(describe test-move-left | |||
(it "Can move two numbers in different rows" | |||
(is (move-left [[nil nil 4 nil] | |||
[nil nil nil nil] | |||
[nil 2 nil nil] | |||
[nil nil nil nil]]) | |||
[[ 4 nil nil nil] | |||
[nil nil nil nil] | |||
[ 2 nil nil nil] | |||
[nil nil nil nil]])))) | |||
[nil nil nil nil]]))) | |||
(deftest test-move-up | |||
(testing "Can move two numbers in different rows" | |||
(is (= (move-up [[nil nil nil nil] | |||
(describe test-move-up | |||
(it "Can move two numbers in different rows" | |||
(is (move-up [[nil nil nil nil] | |||
[nil nil 4 nil] | |||
[nil 2 nil nil] | |||
[nil nil nil nil]]) | |||
[[nil 2 4 nil] | |||
[nil nil nil nil] | |||
[nil nil nil nil] | |||
[nil nil nil nil]])))) | |||
[nil nil nil nil]]))) | |||
(deftest test-move-down | |||
(testing "Can move two numbers in different rows" | |||
(is (= (move-down [[nil nil nil nil] | |||
(describe test-move-down | |||
(it "Can move two numbers in different rows" | |||
(is (move-down [[nil nil nil nil] | |||
[nil nil 4 nil] | |||
[nil 2 nil nil] | |||
[nil nil nil nil]]) | |||
[[nil nil nil nil] | |||
[nil nil nil nil] | |||
[nil nil nil nil] | |||
[nil 2 4 nil]])))) | |||
[nil 2 4 nil]]))) |