[Notice] Announcing the End of Demo Server [Read me]
doortts doortts 2013-01-17
add test for signup validation
@cbd4ee4abc17091322177d3b48413445cfcd3f72
test/controllers/UserAppTest.java
--- test/controllers/UserAppTest.java
+++ test/controllers/UserAppTest.java
@@ -38,7 +38,7 @@
 
                 //Then
                 assertThat(status(result)).isEqualTo(OK);
-                assertThat(contentAsString(result)).contains("{\"isExist\":\"false\"}");
+                assertThat(contentAsString(result)).contains("{\"isExist\":false}");
             }
         });
     }
@@ -59,7 +59,24 @@
 
                 //Then
                 assertThat(status(result)).isEqualTo(OK);
-                assertThat(contentAsString(result)).contains("{\"isExist\":\"true\"}");
+                assertThat(contentAsString(result)).contains("{\"isExist\":true}");
+            }
+        });
+    }
+
+    @Test
+    public void isEmailExist() {
+        running(fakeApplication(), new Runnable() {
+            public void run() {
+                //Given
+                //When
+                Result result = callAction(
+                        controllers.routes.ref.UserApp.isEmailExist("doortts@gmail.com")
+                );
+
+                //Then
+                assertThat(status(result)).isEqualTo(OK);
+                assertThat(contentAsString(result)).contains("{\"isExist\":true}");
             }
         });
     }
test/models/UserTest.java
--- test/models/UserTest.java
+++ test/models/UserTest.java
@@ -101,4 +101,23 @@
 	    assertThat(result2).isEqualTo(false);
 	    assertThat(result3).isEqualTo(false);
 	}
+
+    @Test
+    public void isEmailExist() throws Exception {
+        // Given
+        String expectedUser = "doortts@gmail.com";
+
+    	// When // Then
+        assertThat(User.isEmailExist(expectedUser)).isTrue();
+    }
+
+    @Test
+    public void isEmailExist_nonExist() throws Exception {
+        // Given
+        String expectedEmail = "nekure@gmail.com";
+
+        // When // Then
+        assertThat(User.isEmailExist(expectedEmail)).isFalse();
+    }
+
 }
Add a comment
List