From 4cc62ffacab0e43ff64985afc2aefc9ea124445b Mon Sep 17 00:00:00 2001 From: Mark Schmale Date: Mon, 13 Dec 2010 08:38:02 +0100 Subject: [PATCH] added spec for email validation --- spec/javascripts/validation-spec.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/spec/javascripts/validation-spec.js b/spec/javascripts/validation-spec.js index ab1aa8931..f289f926d 100644 --- a/spec/javascripts/validation-spec.js +++ b/spec/javascripts/validation-spec.js @@ -7,6 +7,13 @@ describe("Validation", function() { }); }); }); + describe("email", function() { + describe("characters", function() { + it("is the regex for checking if the input is a valid list of e-mail addresses", function() { + expect((typeof Validation.rules.email.characters.test === "function")).toBeTruthy(); + }); + }); + }); }); describe("events", function() { describe("usernameKeypress", function() { @@ -16,5 +23,16 @@ describe("Validation", function() { expect(Validation.rules.username.characters.test("ffffffffffffffffffffffffffffffffff")).toBeFalsy(); }); }); + describe("emailKeypress", function() { + it("colors the border red if the input seems to be a invalid list", function() { + expect(Validation.rules.email.characters.test("user@example.com")).toBeTruthy(); + expect(Validation.rules.email.characters.test("user@example.com, user@example.com")).toBeTruthy(); + expect(Validation.rules.email.characters.test("user@example.com, user@example.com, user@example.com")).toBeTruthy(); + expect(Validation.rules.email.characters.test("user@example.com user@example.com")).toBeFalsy(); + expect(Validation.rules.email.characters.test("user@examplecom")).toBeFalsy(); + expect(Validation.rules.email.characters.test("userexample.com")).toBeFalsy(); + expect(Validation.rules.email.characters.test("userexamplecom")).toBeFalsy(); + }); + }); }); });