Skip to content

Commit

Permalink
chore: update to account for the latest changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ST-DDT committed Oct 22, 2022
1 parent e96ac11 commit aee3f68
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/modules/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ export class HelpersModule {
* It is also possible to use multiple parameters (comma separated).
*
* ```js
* const message = faker.helpers.fake('Your pin is {{random.numeric(4, {allowLeadingZeros: true})}}.')
* const message = faker.helpers.fake('Your pin is {{string.numeric(4, {allowLeadingZeros: true})}}.')
* ```
*
* It is also NOT possible to use any non-faker methods or plain javascript in such templates.
Expand All @@ -509,7 +509,7 @@ export class HelpersModule {
* faker.helpers.fake('Good Morning {{person.firstName}}!') // 'Good Morning Estelle!'
* faker.helpers.fake('You can call me at {{phone.number(!## ### #####!)}}.') // 'You can call me at 202 555 973722.'
* faker.helpers.fake('I flipped the coin and got: {{helpers.arrayElement(["heads", "tails"])}}') // 'I flipped the coin and got: tails'
* faker.helpers.fake('I rolled the dice and got: {{random.numeric(1, {"allowLeadingZeros": true})}}') // 'I rolled the dice and got: 6'
* faker.helpers.fake('I rolled the dice and got: {{string.numeric(1, {"allowLeadingZeros": true})}}') // 'I rolled the dice and got: 6'
*
* @since 7.4.0
*/
Expand Down
10 changes: 5 additions & 5 deletions test/helpers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,19 +489,19 @@ describe('helpers', () => {

describe('fake()', () => {
it('replaces a token with a random value for a method without parentheses', () => {
const actual = faker.helpers.fake('{{random.numeric}}');
const actual = faker.helpers.fake('{{string.numeric}}');
expect(actual).toMatch(/^\d$/);
});

it('replaces multiple tokens with random values for methods without parentheses', () => {
const actual = faker.helpers.fake(
'{{random.numeric}}{{random.numeric}}{{random.numeric}}'
'{{string.numeric}}{{string.numeric}}{{string.numeric}}'
);
expect(actual).toMatch(/^\d{3}$/);
});

it('replaces a token with a random value for a method with empty parentheses', () => {
const actual = faker.helpers.fake('{{random.numeric()}}');
const actual = faker.helpers.fake('{{string.numeric()}}');
expect(actual).toMatch(/^\d$/);
});

Expand All @@ -511,7 +511,7 @@ describe('helpers', () => {
});

it('replaces a token with a random value for a method with a simple parameter', () => {
const actual = faker.helpers.fake('{{random.numeric(3)}}');
const actual = faker.helpers.fake('{{string.numeric(3)}}');
expect(actual).toMatch(/^\d{3}$/);
});

Expand All @@ -530,7 +530,7 @@ describe('helpers', () => {

it('replaces a token with a random value for a method with multiple parameters', () => {
const actual = faker.helpers.fake(
'{{random.numeric(5, {"allowLeadingZeros": true})}}'
'{{string.numeric(5, {"allowLeadingZeros": true})}}'
);
expect(actual).toMatch(/^\d{5}$/);
});
Expand Down

0 comments on commit aee3f68

Please sign in to comment.