@@ -2,6 +2,7 @@ import validator from 'validator';
22import { afterEach , describe , expect , it } from 'vitest' ;
33import { faker } from '../src' ;
44import { seededRuns } from './support/seededRuns' ;
5+ import { times } from './support/times' ;
56
67const NON_SEEDED_BASED_RUN = 5 ;
78
@@ -48,15 +49,23 @@ describe('system', () => {
4849 'gif' ,
4950 'htm' ,
5051 'html' ,
52+ 'jpe' ,
5153 'jpeg' ,
54+ 'jpg' ,
55+ 'm1v' ,
5256 'm2a' ,
5357 'm2v' ,
58+ 'm3a' ,
5459 'mp2' ,
60+ 'mp2a' ,
5561 'mp3' ,
5662 'mp4' ,
5763 'mp4v' ,
64+ 'mpe' ,
5865 'mpeg' ,
5966 'mpg' ,
67+ 'mpg4' ,
68+ 'mpga' ,
6069 'pdf' ,
6170 'png' ,
6271 'shtml' ,
@@ -180,6 +189,41 @@ describe('system', () => {
180189 'generated fileNames should have an extension'
181190 ) . toContain ( '.' ) ;
182191 } ) ;
192+
193+ it ( 'should return filenames with 1 ext per default' , ( ) => {
194+ const fileName = faker . system . fileName ( ) ;
195+ const parts = fileName . split ( '.' ) ;
196+
197+ expect ( parts ) . length ( 2 ) ;
198+ } ) ;
199+
200+ it ( 'should return filenames without an extension when extensionCount is 0' , ( ) => {
201+ const fileName = faker . system . fileName ( {
202+ extensionCount : 0 ,
203+ } ) ;
204+
205+ expect ( fileName ) . not . toContain ( '.' ) ;
206+ } ) ;
207+
208+ it ( 'should return filenames without an extension when extensionCount is negative' , ( ) => {
209+ const fileName = faker . system . fileName ( {
210+ extensionCount : - 1 ,
211+ } ) ;
212+
213+ expect ( fileName ) . not . toContain ( '.' ) ;
214+ } ) ;
215+
216+ it . each ( times ( 10 ) ) (
217+ 'should return filenames with %s extensions' ,
218+ ( extensionCount ) => {
219+ const fileName = faker . system . fileName ( {
220+ extensionCount,
221+ } ) ;
222+ const parts = fileName . split ( '.' ) ;
223+
224+ expect ( parts ) . length ( extensionCount + 1 ) ;
225+ }
226+ ) ;
183227 } ) ;
184228
185229 describe ( 'filePath()' , ( ) => {
0 commit comments