11import { beforeEach , describe , expect , it } from 'vitest' ;
22import { faker } from '../src' ;
3+ import { luhnCheck } from './support/luhnCheck' ;
34
45const seededRuns = [
56 {
@@ -15,6 +16,9 @@ const seededRuns = [
1516 phoneFormats : {
1617 noArgs : '!##.!##.####' ,
1718 } ,
19+ imei : {
20+ noArgs : '37-917755-141004-5' ,
21+ } ,
1822 } ,
1923 } ,
2024 {
@@ -30,6 +34,9 @@ const seededRuns = [
3034 phoneFormats : {
3135 noArgs : '(!##) !##-####' ,
3236 } ,
37+ imei : {
38+ noArgs : '25-122540-325523-6' ,
39+ } ,
3340 } ,
3441 } ,
3542 {
@@ -45,11 +52,19 @@ const seededRuns = [
4552 phoneFormats : {
4653 noArgs : '1-!##-!##-#### x#####' ,
4754 } ,
55+ imei : {
56+ noArgs : '94-872190-616274-6' ,
57+ } ,
4858 } ,
4959 } ,
5060] ;
5161
52- const functionNames = [ 'phoneNumber' , 'phoneNumberFormat' , 'phoneFormats' ] ;
62+ const functionNames = [
63+ 'phoneNumber' ,
64+ 'phoneNumberFormat' ,
65+ 'phoneFormats' ,
66+ 'imei' ,
67+ ] ;
5368
5469const NON_SEEDED_BASED_RUN = 25 ;
5570
@@ -125,6 +140,23 @@ describe('phone', () => {
125140 expect ( faker . definitions . phone_number . formats ) . contain ( phoneFormat ) ;
126141 } ) ;
127142 } ) ;
143+
144+ describe ( 'imei()' , ( ) => {
145+ it ( 'should return a string' , ( ) => {
146+ const imei = faker . phone . imei ( ) ;
147+ expect ( imei ) . toBeTypeOf ( 'string' ) ;
148+ } ) ;
149+
150+ it ( 'should have a length of 18' , ( ) => {
151+ const imei = faker . phone . imei ( ) ;
152+ expect ( imei ) . toHaveLength ( 18 ) ;
153+ } ) ;
154+
155+ it ( 'should be Luhn-valid' , ( ) => {
156+ const imei = faker . phone . imei ( ) ;
157+ expect ( imei ) . satisfy ( luhnCheck ) ;
158+ } ) ;
159+ } ) ;
128160 }
129161 } ) ;
130162} ) ;
0 commit comments