这是indexloc提供的服务,不要输入任何密码
Skip to content

Commit 2c60ddd

Browse files
committed
feat(New Profile Property): Added SSN to the profile
Added the support for random SSN to the generated profile and ability to get random SSN numbers. closes #9
1 parent e78a1ee commit 2c60ddd

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ function profile() {
2323
profile.phone = chance.phone();
2424
profile.email = chance.email();
2525
profile.twitter = chance.twitter();
26+
profile.ssn = chance.ssn();
2627

2728
return profile;
2829
}
@@ -51,6 +52,10 @@ function twitter() {
5152
return chance.twitter();
5253
}
5354

55+
function ssn() {
56+
return chance.ssn();
57+
}
58+
5459
module.exports = {
5560
profile: profile,
5661
randomName: uniqueRandomArray(allNames),
@@ -60,5 +65,6 @@ module.exports = {
6065
randomAvatar: avatar,
6166
randomPhone: phone,
6267
randomEmail: email,
63-
randomTwitter: twitter
68+
randomTwitter: twitter,
69+
randomSSN: ssn
6470
};

tests/index.test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ describe('Random Profile Generator', () => {
6666
expect(randomProfiles.profile().twitter).to.be.a('string');
6767
expect(randomProfiles.profile().twitter).to.match(/([@][A-z]+)|([#][A-z]+)/);
6868
});
69+
70+
it('Should contain `ssn` property, it should a string and a valid SSN', () => {
71+
expect(randomProfiles.profile()).to.have.property('ssn');
72+
expect(randomProfiles.profile().ssn).to.be.a('string');
73+
expect(randomProfiles.profile().ssn).to.match(/(\d{3}[-]\d{2}[-]\d{4})/);
74+
});
6975
});
7076

7177
describe('Calling `randomName`', () => {
@@ -174,5 +180,19 @@ describe('Random Profile Generator', () => {
174180
it('Should return a string that is a valid twitter handle', () => {
175181
expect(randomProfiles.randomTwitter()).to.match(/([@][A-z]+)|([#][A-z]+)/);
176182
});
183+
});
184+
185+
describe('Calling `randomSSN`', () => {
186+
it('Should be a function', () => {
187+
expect(randomProfiles.randomSSN).to.be.a('function');
188+
});
189+
190+
it('Should return a type string', () => {
191+
expect(randomProfiles.randomSSN()).to.be.a('string');
192+
});
193+
194+
it('Should return a string that is a valid twitter handle', () => {
195+
expect(randomProfiles.randomSSN()).to.match(/(\d{3}[-]\d{2}[-]\d{4})/);
196+
});
177197
});
178198
});

0 commit comments

Comments
 (0)