Skip to content

Commit 8f40d2b

Browse files
authored
test: fix random alpha and alphaNumeric tests assumptions (#774)
1 parent 845c6db commit 8f40d2b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

test/random.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,12 @@ describe('random', () => {
187187
it('should return lowercase letter when no upcase option provided', () => {
188188
const actual = faker.random.alpha();
189189

190-
expect(actual).match(/[a-z]/);
190+
expect(actual).match(/^[a-z]$/);
191191
});
192192

193193
it('should return uppercase when upcase option is true', () => {
194194
const actual = faker.random.alpha({ upcase: true });
195-
expect(actual).match(/[A-Z]/);
195+
expect(actual).match(/^[A-Z]$/);
196196
});
197197

198198
it('should generate many random letters', () => {
@@ -208,7 +208,7 @@ describe('random', () => {
208208
});
209209

210210
expect(actual).toHaveLength(5);
211-
expect(actual).match(/[b-oq-z]/);
211+
expect(actual).match(/^[b-oq-z]{5}$/);
212212
});
213213

214214
it('should be able handle mistake in banned characters array', () => {
@@ -218,7 +218,7 @@ describe('random', () => {
218218
});
219219

220220
expect(alphaText).toHaveLength(5);
221-
expect(alphaText).match(/[b-oq-z]/);
221+
expect(alphaText).match(/^[b-oq-z]{5}$/);
222222
});
223223
});
224224

@@ -265,7 +265,7 @@ describe('random', () => {
265265
});
266266

267267
expect(alphaText).toHaveLength(5);
268-
expect(alphaText).match(/[b-oq-z]/);
268+
expect(alphaText).match(/^[0-9b-oq-z]{5}$/);
269269
});
270270

271271
it('should throw if all possible characters being banned', () => {

0 commit comments

Comments
 (0)