Permalink
Browse files

Adding some tests

  • Loading branch information...
1 parent e1c3510 commit 11fc59e9781c1b42717999ce44b6eeee713c639b @oliyh committed Dec 24, 2016
Showing with 26 additions and 2 deletions.
  1. +1 −1 src/re_learn/model.cljs
  2. +25 −1 test/re_learn/model_test.cljs
@@ -15,7 +15,7 @@
(def ^:private interceptors
[(re-frame/path state)
- re-frame/debug
+ ;;re-frame/debug
re-frame/trim-v
(re-frame/after validate-schema)])
@@ -9,13 +9,37 @@
{:id :a-lesson
:description "A test lesson"})
+(deftest current-lesson-test
+ (run-test-sync
+ (re-frame/dispatch [::model/init])
+
+ (let [lesson (re-frame/subscribe [::model/current-lesson])]
+ (testing "there are no lessons at first"
+ (is (nil? @lesson)))
+
+ (testing "a registered lesson appears first with defaults"
+ (re-frame/dispatch [::model/register-lesson a-lesson])
+ (is (= (assoc a-lesson :version 1 :position :right) @lesson)))
+
+ (testing "another lesson doesn't show up at first"
+ (re-frame/dispatch [::model/register-lesson (assoc a-lesson :id :another-lesson)])
+ (is (= :a-lesson (:id @lesson)))
+
+ (testing "until the first lesson is learned"
+ (re-frame/dispatch [::model/lesson-learned :a-lesson])
+ (is (= :another-lesson (:id @lesson)))))
+
+ (testing "lessons can be unlearned"
+ (re-frame/dispatch [::model/lesson-unlearned :a-lesson])
+ (is (= :a-lesson (:id @lesson)))))))
+
(deftest tutorial-precedence-test
(run-test-sync
(re-frame/dispatch [::model/init])
(let [tutorial (re-frame/subscribe [::model/current-tutorial])]
(testing "there are no tutorials at first"
- (is (= nil @tutorial)))
+ (is (nil? @tutorial)))
(testing "a registered tutorial appears first"
(re-frame/dispatch [::model/register-tutorial {:id :less-important

0 comments on commit 11fc59e

Please sign in to comment.