tests adjusted
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
(ns NoteHub.test.crossover.lib
|
||||
(:require [NoteHub.crossover.lib :as lib])
|
||||
(:use [clojure.test]))
|
||||
|
||||
(with-test
|
||||
(defn lib-hash [s]
|
||||
(lib/hash #(.codePointAt % 0) s))
|
||||
(testing "Crossover Lib:"
|
||||
(testing "Self-made hash function"
|
||||
(testing "for correct hashes"
|
||||
(is (= 0 (lib-hash "")))
|
||||
(is (= 6178 (lib-hash "test тест")))
|
||||
(is (= 6178 (lib-hash (str "test\n \rтест"))))
|
||||
(is (= 274 (lib-hash "Hello world!"))))
|
||||
(testing "for a wrong hash"
|
||||
(is (not= 6178 (lib-hash "wrong hash")))))))
|
||||
@@ -1,5 +1,4 @@
|
||||
(ns NoteHub.test.views.pages
|
||||
(:require [NoteHub.crossover.lib :as lib])
|
||||
(:use [NoteHub.views.pages]
|
||||
[noir.util.test]
|
||||
[NoteHub.views.common :only [url]]
|
||||
@@ -27,10 +26,6 @@
|
||||
(is (= (get-note date test-title) test-note))
|
||||
(is (note-exists? date test-title))))
|
||||
|
||||
(deftest helper-functions
|
||||
(testing "Markdown generation"
|
||||
(is (= "<h1><em>hellö</em> <strong>world</strong></h1><p>test <code>code</code></p>"
|
||||
(md-to-html "#_hellö_ __world__\ntest `code`")))))
|
||||
(deftest export-test
|
||||
(testing "Markdown export"
|
||||
(is (has-body (send-request (url 2012 6 3 "some-title" "export")) test-note))))
|
||||
@@ -46,10 +41,9 @@
|
||||
[:post "/post-note"]
|
||||
{:session-key session-key
|
||||
:draft test-note
|
||||
:session-value (str (lib/hash #(.codePointAt % 0)
|
||||
(str test-note session-key)))}) 302))
|
||||
:session-value (str (get-hash (str test-note session-key)))}) 302))
|
||||
(is (note-exists? date title))
|
||||
(is (substring? "Hello <em>world</em>"
|
||||
(is (substring? "Hello _world_"
|
||||
((send-request (url year month day title)) :body)))
|
||||
(is (do
|
||||
(delete-note date title)
|
||||
@@ -67,8 +61,7 @@
|
||||
{:session-key session-key
|
||||
:draft "test note"
|
||||
:password "qwerty"
|
||||
:session-value (str (lib/hash #(.codePointAt % 0)
|
||||
(str "test note" session-key)))}) 302))
|
||||
:session-value (str (get-hash (str "test note" session-key)))}) 302))
|
||||
(is (note-exists? date title))
|
||||
(is (substring? "test note"
|
||||
((send-request (url year month day title)) :body)))
|
||||
@@ -108,3 +101,13 @@
|
||||
(is (has-status (send-request (url 2012 6 3 "some-title" "export")) 200) "accessing test note's export")
|
||||
(is (has-status (send-request (url 2012 6 3 "some-title" "stats")) 200) "accessing test note's stats")
|
||||
(is (has-status (send-request "/") 200) "accessing landing page"))))
|
||||
|
||||
(deftest hash-function
|
||||
(testing "Self-made hash function"
|
||||
(testing "for correct hashes"
|
||||
(is (= 0 (get-hash "")))
|
||||
(is (= 6178 (get-hash "test тест")))
|
||||
(is (= 6178 (get-hash (str "test\n \rтест"))))
|
||||
(is (= 274 (get-hash "Hello world!"))))
|
||||
(testing "for a wrong hash"
|
||||
(is (not= 6178 (get-hash "wrong hash"))))))
|
||||
|
||||
Reference in New Issue
Block a user