import * as SUT from './index' ; describe ( 'filename generator' , ( ) : void => { test ( 'should generate uniqe filenames when no options' , async ( ) : Promise < void > => { const filenames = new Set ( ) ; const count = 100 ; for ( let index = 1 ; index <= count ; index ++ ) { filenames . add ( SUT . uniqueFilename ( ) ) ; } expect ( filenames . size ) . toBe ( 100 ) ; } ) ; test ( 'should generate uniqe filenames with prefix' , async ( ) : Promise < void > => { const filenames = new Set < string > ( ) ; const count = 100 ; const prefix = 'har-' ; for ( let index = 1 ; index <= count ; index ++ ) { filenames . add ( SUT . uniqueFilename ( { prefix } ) ) ; } expect ( filenames . size ) . toBe ( 100 ) ; filenames . forEach ( ( filename ) => { expect ( filename . startsWith ( prefix ) ) . toBe ( true ) ; expect ( filename . endsWith ( '.json' ) ) . toBe ( true ) ; } ) ; } ) ; test ( 'should generate uniqe filenames with prefix and extension' , async ( ) : Promise < void > => { const filenames = new Set < string > ( ) ; const count = 100 ; const prefix = 'har-' ; const extension = '.foobar' ; for ( let index = 1 ; index <= count ; index ++ ) { filenames . add ( SUT . uniqueFilename ( { prefix , extension } ) ) ; } expect ( filenames . size ) . toBe ( 100 ) ; filenames . forEach ( ( filename ) => { expect ( filename . startsWith ( prefix ) ) . toBe ( true ) ; expect ( filename . endsWith ( extension ) ) . toBe ( true ) ; } ) ; } ) ; } ) ;