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