From 8f40d2b1a6044467b5ec23a0f6aaf46cfca6c9a1 Mon Sep 17 00:00:00 2001 From: ST-DDT Date: Mon, 4 Apr 2022 17:36:18 +0200 Subject: [PATCH] test: fix random alpha and alphaNumeric tests assumptions (#774) --- test/random.spec.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/random.spec.ts b/test/random.spec.ts index c0885b2ddd6..79dbf18d5ef 100644 --- a/test/random.spec.ts +++ b/test/random.spec.ts @@ -187,12 +187,12 @@ describe('random', () => { it('should return lowercase letter when no upcase option provided', () => { const actual = faker.random.alpha(); - expect(actual).match(/[a-z]/); + expect(actual).match(/^[a-z]$/); }); it('should return uppercase when upcase option is true', () => { const actual = faker.random.alpha({ upcase: true }); - expect(actual).match(/[A-Z]/); + expect(actual).match(/^[A-Z]$/); }); it('should generate many random letters', () => { @@ -208,7 +208,7 @@ describe('random', () => { }); expect(actual).toHaveLength(5); - expect(actual).match(/[b-oq-z]/); + expect(actual).match(/^[b-oq-z]{5}$/); }); it('should be able handle mistake in banned characters array', () => { @@ -218,7 +218,7 @@ describe('random', () => { }); expect(alphaText).toHaveLength(5); - expect(alphaText).match(/[b-oq-z]/); + expect(alphaText).match(/^[b-oq-z]{5}$/); }); }); @@ -265,7 +265,7 @@ describe('random', () => { }); expect(alphaText).toHaveLength(5); - expect(alphaText).match(/[b-oq-z]/); + expect(alphaText).match(/^[0-9b-oq-z]{5}$/); }); it('should throw if all possible characters being banned', () => {