Skip to content

Commit

Permalink
fix: fake is unable to return empty strings (#347)
Browse files Browse the repository at this point in the history
  • Loading branch information
ST-DDT committed Mar 24, 2022
1 parent 9ce1551 commit 301a6d2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/fake.ts
Expand Up @@ -116,6 +116,10 @@ export class Fake {
// replace the found tag with the returned fake value
res = str.replace('{{' + token + '}}', result);

if (res === '') {
return '';
}

// return the response recursively until we are done finding all tags
return this.fake(res);
}
Expand Down
4 changes: 4 additions & 0 deletions test/fake.spec.ts
Expand Up @@ -46,5 +46,9 @@ describe('fake', () => {
Error('Invalid method: address.foo')
);
});

it('should be able to return empty strings', () => {
expect(faker.fake('{{helpers.repeatString}}')).toBe('');
});
});
});

0 comments on commit 301a6d2

Please sign in to comment.