Skip to content

Commit 6f2b748

Browse files
author
cbojar
committed
Add tests to check for correctness of parser.
-Test suite is QUnit http://qunitjs.com/ -Tests copied from fork of this project at https://github.com/chris-rock/node-humanname/blob/012dd6b0cfbb21468121d38b4911767697927c0d/test/test.js -All tests pass. Yay!
1 parent 4268180 commit 6f2b748

File tree

1 file changed

+106
-0
lines changed

1 file changed

+106
-0
lines changed

parse-names-test.html

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<!DOCTYPE html>
2+
<html lang="en-us">
3+
<head>
4+
<title>Javascript Name Parser Unit Tests</title>
5+
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.14.0.css" />
6+
</head>
7+
<body>
8+
<div id="qunit"></div>
9+
<div id="qunit-fixture"></div>
10+
<script src="http://code.jquery.com/qunit/qunit-1.14.0.js"></script>
11+
<script src="parse-names.js"></script>
12+
<script>
13+
var names = [
14+
{
15+
name: "John Doe",
16+
result: {
17+
"salutation": "",
18+
"firstName": "John",
19+
"initials": "",
20+
"lastName": "Doe",
21+
"suffix": ""
22+
}
23+
}, {
24+
name: "Mr Anthony R Von Fange III",
25+
result: {
26+
"salutation": "Mr.",
27+
"firstName": "Anthony",
28+
"initials": "R",
29+
"lastName": "Von Fange",
30+
"suffix": "III"
31+
}
32+
}, {
33+
name: "Sara Ann Fraser",
34+
result: {
35+
"salutation": "",
36+
"firstName": "Sara Ann",
37+
"initials": "",
38+
"lastName": "Fraser",
39+
"suffix": ""
40+
}
41+
}, {
42+
name: "Adam",
43+
result: {
44+
"salutation": "",
45+
"firstName": "Adam",
46+
"initials": "",
47+
"lastName": "",
48+
"suffix": ""
49+
}
50+
}, {
51+
name: "Jonathan Smith",
52+
result: {
53+
"salutation": "",
54+
"firstName": "Jonathan",
55+
"initials": "",
56+
"lastName": "Smith",
57+
"suffix": ""
58+
}
59+
}, {
60+
name: "Anthony Von Fange III",
61+
result: {
62+
"salutation": "",
63+
"firstName": "Anthony",
64+
"initials": "",
65+
"lastName": "Von Fange",
66+
"suffix": "III"
67+
}
68+
}, {
69+
name: "Mr John Doe",
70+
result: {
71+
"salutation": "Mr.",
72+
"firstName": "John",
73+
"initials": "",
74+
"lastName": "Doe",
75+
"suffix": ""
76+
}
77+
}, {
78+
name: "Smarty Pants Phd",
79+
result: {
80+
"salutation": "",
81+
"firstName": "Smarty",
82+
"initials": "",
83+
"lastName": "Pants",
84+
"suffix": "PhD"
85+
}
86+
}, {
87+
name: "Mark P Williams",
88+
result: {
89+
"salutation": "",
90+
"firstName": "Mark",
91+
"initials": "P",
92+
"lastName": "Williams",
93+
"suffix": ""
94+
}
95+
}];
96+
97+
test('Test names', function() {
98+
names.forEach(function(testCase){
99+
console.log("Check Name: %s", testCase.name);
100+
var parsed = NameParse.parse(testCase.name);
101+
propEqual(parsed, testCase.result);
102+
});
103+
});
104+
</script>
105+
</body>
106+
</html>

0 commit comments

Comments
 (0)