Guest User

Untitled

a guest
Feb 19th, 2018
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>Jasmine Test Runner</title>
  4. <link rel="stylesheet" type="text/css" href="lib/jasmine-1.0.2/jasmine.css">
  5. <script type="text/javascript" src="lib/jasmine-1.0.2/jasmine.js"></script>
  6. <script type="text/javascript" src="lib/jasmine-1.0.2/jasmine-html.js"></script>
  7. </head>
  8. <body>
  9.  
  10. <script type="text/javascript">
  11. var Validation = function() {
  12. };
  13. Validation.prototype.isValidEmail = function (email){
  14. var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
  15. if(emailPattern.test(email)) {
  16. return "Valid";
  17. }
  18. };
  19.  
  20. Validation.prototype.isValidNameSurname = function (name){
  21. var namePattern = /^[a-zA-Z ]{5,30}$/;
  22. if(namePattern.test(name)) {
  23. return "Valid";
  24. }
  25. };
  26.  
  27. Validation.prototype.isValidZipCode = function (post){
  28. var postPattern = /^[0-9]{5}$/;
  29. if(postPattern.test(post)) {
  30. return "Valid";
  31. }
  32. };
  33. // ---------------
  34.  
  35. describe("Email Valid", function() {
  36.  
  37. var valider ;
  38. beforeEach(function() {
  39. valider = new Validation();
  40. });
  41.  
  42.  
  43. describe("For string that are Email Adress, output the exact string Valid", function() {
  44.  
  45. it("should return Valid for real Email Address", function() {
  46. var result = valider.isValidEmail("mehmettamturk@hotmail.com");
  47. expect(result).toEqual("Valid");
  48. });
  49. });
  50.  
  51. describe("For string that are Name, output the exact string Valid", function() {
  52.  
  53. it("should return Valid for real Name", function() {
  54. var result = valider.isValidNameSurname("Mehmet Tamturk");
  55. expect(result).toEqual("Valid");
  56. });
  57. });
  58.  
  59. describe("For string that are PostCode, output the exact string Valid", function() {
  60.  
  61. it("should return Valid for real PostCode", function() {
  62. var result = valider.isValidZipCode("12345");
  63. expect(result).toEqual("Valid");
  64. });
  65. });
  66. });
  67.  
  68. jasmine.getEnv()['addReporter'](new jasmine.TrivialReporter());
  69. jasmine.getEnv()['execute']();
  70.  
  71. </script>
  72.  
  73. </body>
  74. </html>
Add Comment
Please, Sign In to add comment