aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/fake.spec.ts34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/fake.spec.ts b/test/fake.spec.ts
index a78940ea..530d09d2 100644
--- a/test/fake.spec.ts
+++ b/test/fake.spec.ts
@@ -50,5 +50,39 @@ describe('fake', () => {
it('should be able to return empty strings', () => {
expect(faker.fake('{{helpers.repeatString}}')).toBe('');
});
+
+ it('should be able to handle only {{ brackets', () => {
+ expect(faker.fake('{{hello')).toBe('{{hello');
+ expect(faker.fake('hello{{')).toBe('hello{{');
+ });
+
+ it('should be able to handle only }} brackets', () => {
+ expect(faker.fake('hello}}')).toBe('hello}}');
+ expect(faker.fake('}}hello')).toBe('}}hello');
+ });
+
+ it('should be able to handle reverted brackets', () => {
+ expect(faker.fake('}}hello{{')).toBe('}}hello{{');
+ });
+
+ it('should be able to handle random }} brackets', () => {
+ expect(faker.fake('}}hello{{random.alpha}}')).toMatch(/^}}hello[a-z]$/);
+ });
+
+ it('should be able to handle connected brackets', () => {
+ expect(faker.fake('{{{random.alpha}}}')).toMatch(/^{[a-z]}$/);
+ });
+
+ it('should be able to handle empty brackets', () => {
+ expect(faker.fake('{{}}')).toBe('{{}}');
+ });
+
+ it('should be able to handle special replacement patterns', () => {
+ (faker.random as any).special = () => '$&';
+
+ expect(faker.fake('{{random.special}}')).toBe('$&');
+
+ delete (faker.random as any).special;
+ });
});
});