File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff 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+
5459module . 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} ;
Original file line number Diff line number Diff 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} ) ;
You can’t perform that action at this time.
0 commit comments