@@ -38,20 +38,52 @@ describe('fake', () => {
3838
3939 it ( 'does not allow invalid module name' , ( ) => {
4040 expect ( ( ) => faker . fake ( '{{foo.bar}}' ) ) . toThrowError (
41- new FakerError ( 'Invalid module: foo' )
41+ new FakerError ( `Invalid module method or definition: foo.bar
42+ - faker.foo.bar is not a function
43+ - faker.definitions.foo.bar is not an array` )
44+ ) ;
45+ } ) ;
46+
47+ it ( 'does not allow missing method name' , ( ) => {
48+ expect ( ( ) => faker . fake ( '{{address}}' ) ) . toThrowError (
49+ new FakerError ( `Invalid module method or definition: address
50+ - faker.address is not a function
51+ - faker.definitions.address is not an array` )
4252 ) ;
4353 } ) ;
4454
4555 it ( 'does not allow invalid method name' , ( ) => {
4656 expect ( ( ) => faker . fake ( '{{address.foo}}' ) ) . toThrowError (
47- new FakerError ( 'Invalid method: address.foo' )
57+ new FakerError ( `Invalid module method or definition: address.foo
58+ - faker.address.foo is not a function
59+ - faker.definitions.address.foo is not an array` )
60+ ) ;
61+ } ) ;
62+
63+ it ( 'does not allow invalid definitions data' , ( ) => {
64+ expect ( ( ) => faker . fake ( '{{finance.credit_card}}' ) ) . toThrowError (
65+ new FakerError ( `Invalid module method or definition: finance.credit_card
66+ - faker.finance.credit_card is not a function
67+ - faker.definitions.finance.credit_card is not an array` )
4868 ) ;
4969 } ) ;
5070
5171 it ( 'should be able to return empty strings' , ( ) => {
5272 expect ( faker . fake ( '{{helpers.repeatString}}' ) ) . toBe ( '' ) ;
5373 } ) ;
5474
75+ it ( 'should be able to return locale definition strings' , ( ) => {
76+ expect ( faker . definitions . cell_phone . formats ) . toContain (
77+ faker . fake ( '{{cell_phone.formats}}' )
78+ ) ;
79+ } ) ;
80+
81+ it ( 'should be able to return locale definition strings that starts with the name of an existing module' , ( ) => {
82+ expect ( faker . definitions . address . city_name ) . toContain (
83+ faker . fake ( '{{address.city_name}}' )
84+ ) ;
85+ } ) ;
86+
5587 it ( 'should be able to handle only {{ brackets' , ( ) => {
5688 expect ( faker . fake ( '{{hello' ) ) . toBe ( '{{hello' ) ;
5789 expect ( faker . fake ( 'hello{{' ) ) . toBe ( 'hello{{' ) ;
0 commit comments