@@ -724,11 +724,50 @@ describe('helpers', () => {
724724 } ) ;
725725
726726 describe ( 'mustache()' , ( ) => {
727- it ( 'returns empty string with no arguments' , ( ) => {
728- expect (
729- // @ts -expect-error
730- faker . helpers . mustache ( )
731- ) . toBe ( '' ) ;
727+ it ( 'returns empty string with no template input' , ( ) => {
728+ expect ( faker . helpers . mustache ( undefined , { } ) ) . toBe ( '' ) ;
729+ } ) ;
730+
731+ it ( 'returns empty string with empty template input' , ( ) => {
732+ expect ( faker . helpers . mustache ( '' , { } ) ) . toBe ( '' ) ;
733+ } ) ;
734+
735+ it ( 'supports string replace values' , ( ) => {
736+ const actual = faker . helpers . mustache ( '1{{value}}3' , { value : '2' } ) ;
737+
738+ expect ( actual ) . toBe ( '123' ) ;
739+ } ) ;
740+
741+ it ( 'supports function replace values faker values' , ( ) => {
742+ const actual = faker . helpers . mustache ( '1{{value}}3' , {
743+ value : faker . datatype . string ( 2 ) ,
744+ } ) ;
745+
746+ expect ( actual ) . toHaveLength ( 4 ) ;
747+ } ) ;
748+
749+ it ( 'supports function replace values faker function' , ( ) => {
750+ const actual = faker . helpers . mustache ( '1{{value}}3' , {
751+ value : ( ) => faker . datatype . string ( 3 ) ,
752+ } ) ;
753+
754+ expect ( actual ) . toHaveLength ( 5 ) ;
755+ } ) ;
756+
757+ it ( 'supports function replace values no args' , ( ) => {
758+ const actual = faker . helpers . mustache ( '1{{value}}3' , {
759+ value : ( ) => '7' ,
760+ } ) ;
761+
762+ expect ( actual ) . toBe ( '173' ) ;
763+ } ) ;
764+
765+ it ( 'supports function replace values with args' , ( ) => {
766+ const actual = faker . helpers . mustache ( '1{{value}}3' , {
767+ value : ( key ) => String ( key . length ) ,
768+ } ) ;
769+
770+ expect ( actual ) . toBe ( '193' ) ;
732771 } ) ;
733772 } ) ;
734773
0 commit comments