Skip to content

Commit fb1b87e

Browse files
authored
fix: random word fails on undefined (#771)
1 parent 8b545b4 commit fb1b87e

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/random.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ export class Random {
326326
const randomWordMethod = this.faker.random.arrayElement(wordMethods);
327327

328328
result = randomWordMethod();
329-
} while (bannedChars.some((char) => result.includes(char)));
329+
} while (!result || bannedChars.some((char) => result.includes(char)));
330330

331331
return this.faker.random.arrayElement(result.split(' '));
332332
}

test/system.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,4 +268,19 @@ describe('system', () => {
268268
});
269269
}
270270
});
271+
272+
describe('extra tests', () => {
273+
describe('commonFileName()', () => {
274+
afterEach(() => {
275+
faker.locale = 'en';
276+
});
277+
278+
it('#770', () => {
279+
faker.seed(5423027051750305);
280+
faker.setLocale('sk');
281+
faker.system.commonFileName('xml');
282+
faker.system.commonFileName('xml');
283+
});
284+
});
285+
});
271286
});

0 commit comments

Comments
 (0)