-
-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Consider all domain suffixes in Clojure
- Loading branch information
Showing
3 changed files
with
40 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,35 +5,50 @@ | |
(ns clojure.test.example | ||
(:use clojure.test)) | ||
|
||
(defn expect-valid-result [expected-valid email] | ||
(is (= expected-valid (mailchecker/valid? email)))) | ||
|
||
(def expect-invalid (partial expect-valid-result false)) | ||
(def expect-valid (partial expect-valid-result true)) | ||
|
||
; Valid | ||
(deftest true-for-valid-1 | ||
(is (= true (mailchecker/valid? "[email protected]")))) | ||
(expect-valid "[email protected]")) | ||
(deftest true-for-valid-2 | ||
(is (= true (mailchecker/valid? "[email protected]")))) | ||
(expect-valid "[email protected]")) | ||
(deftest true-for-valid-3 | ||
(is (= true (mailchecker/valid? "[email protected]")))) | ||
(expect-valid "[email protected]")) | ||
(deftest true-for-valid-4 | ||
(is (= true (mailchecker/valid? "[email protected]")))) | ||
(expect-valid "[email protected]")) | ||
(deftest true-for-valid-5 | ||
(is (= true (mailchecker/valid? "[email protected]")))) | ||
(expect-valid "[email protected]")) | ||
(deftest true-for-valid-6 | ||
(is (= true (mailchecker/valid? "[email protected]")))) | ||
(expect-valid "[email protected]")) | ||
|
||
; Invalid | ||
(deftest false-for-invalid-1 | ||
(is(= false (mailchecker/valid? "plopplop.com")))) | ||
(expect-invalid "plopplop.com")) | ||
(deftest false-for-invalid-2 | ||
(is(= false (mailchecker/valid? "my+ok@ok=plop.com")))) | ||
(expect-invalid "my+ok@ok=plop.com")) | ||
(deftest false-for-invalid-3 | ||
(is(= false (mailchecker/valid? "my,[email protected]")))) | ||
(expect-invalid "my,[email protected]")) | ||
|
||
(deftest false-for-spam-1 | ||
(is(= false (mailchecker/valid? "[email protected]")))) | ||
(expect-invalid "[email protected]")) | ||
(deftest false-for-spam-2 | ||
(is(= false (mailchecker/valid? "[email protected]")))) | ||
(expect-invalid "[email protected]")) | ||
(deftest false-for-spam-3 | ||
(is(= false (mailchecker/valid? "[email protected]")))) | ||
(expect-invalid "[email protected]")) | ||
(deftest false-for-spam-4 | ||
(is(= false (mailchecker/valid? "[email protected]")))) | ||
(expect-invalid "[email protected]")) | ||
|
||
(deftest false-for-blacklist-entries | ||
(every? (fn [domain] | ||
(do (expect-invalid (str "test@" domain)) | ||
(expect-invalid (str "test@subdomain." domain)) | ||
;; Blacklisted domains should be valid as subdomains of a | ||
;; valid domain. | ||
(expect-valid (str "test@" domain ".gmail.com")))) | ||
mailchecker/blacklist)) | ||
|
||
(run-all-tests) |