aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorST-DDT <[email protected]>2022-04-04 17:01:18 +0200
committerGitHub <[email protected]>2022-04-04 15:01:18 +0000
commitfb1b87e2249798c6257cb5383f73a15022f438f0 (patch)
treed20171e5380cfc448422fdcb87bbb1b11aebcf55
parent8b545b4e72e0d00f93d51f8de876103bedebff03 (diff)
downloadfaker-fb1b87e2249798c6257cb5383f73a15022f438f0.tar.xz
faker-fb1b87e2249798c6257cb5383f73a15022f438f0.zip
fix: random word fails on undefined (#771)
-rw-r--r--src/random.ts2
-rw-r--r--test/system.spec.ts15
2 files changed, 16 insertions, 1 deletions
diff --git a/src/random.ts b/src/random.ts
index a653472f..448cf4f8 100644
--- a/src/random.ts
+++ b/src/random.ts
@@ -326,7 +326,7 @@ export class Random {
const randomWordMethod = this.faker.random.arrayElement(wordMethods);
result = randomWordMethod();
- } while (bannedChars.some((char) => result.includes(char)));
+ } while (!result || bannedChars.some((char) => result.includes(char)));
return this.faker.random.arrayElement(result.split(' '));
}
diff --git a/test/system.spec.ts b/test/system.spec.ts
index de7d0390..26b5730f 100644
--- a/test/system.spec.ts
+++ b/test/system.spec.ts
@@ -268,4 +268,19 @@ describe('system', () => {
});
}
});
+
+ describe('extra tests', () => {
+ describe('commonFileName()', () => {
+ afterEach(() => {
+ faker.locale = 'en';
+ });
+
+ it('#770', () => {
+ faker.seed(5423027051750305);
+ faker.setLocale('sk');
+ faker.system.commonFileName('xml');
+ faker.system.commonFileName('xml');
+ });
+ });
+ });
});