aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorST-DDT <[email protected]>2022-01-23 12:30:48 +0100
committerGitHub <[email protected]>2022-01-23 12:30:48 +0100
commit6ba72a42aef3c244ec0dac29955ac49c161c0c1b (patch)
treef7a47d994773d1edfa8d1aee69c7b0da1dcc7d9d
parent74204a0ded997b08a988fe20481a715081b7daf6 (diff)
downloadfaker-6ba72a42aef3c244ec0dac29955ac49c161c0c1b.tar.xz
faker-6ba72a42aef3c244ec0dac29955ac49c161c0c1b.zip
chore(test): Add locale to test description (#262)
-rw-r--r--test/all_functional.spec.ts76
1 files changed, 40 insertions, 36 deletions
diff --git a/test/all_functional.spec.ts b/test/all_functional.spec.ts
index 779d8335..a450530f 100644
--- a/test/all_functional.spec.ts
+++ b/test/all_functional.spec.ts
@@ -31,13 +31,13 @@ function isTestableMethod(mod: string) {
function both(
pred1: (meth: string) => boolean,
pred2: (meth: string) => boolean
-) {
+): (meth: string) => boolean {
return (value) => pred1(value) && pred2(value);
}
// Basic smoke tests to make sure each method is at least implemented and returns a value.
-function modulesList() {
+function modulesList(): { [module: string]: string[] } {
const modules = Object.keys(faker)
.filter(isTestableModule)
.reduce((result, mod) => {
@@ -54,22 +54,24 @@ const modules = modulesList();
describe('functional tests', () => {
for (const locale in faker.locales) {
- faker.locale = locale;
- Object.keys(modules).forEach((module) => {
- describe(module, () => {
- // if there is nothing to test, create a dummy test so the test runner doesn't complain
- if (Object.keys(modules[module]).length === 0) {
- it.todo(`${module} was empty`);
- }
+ describe(locale, () => {
+ faker.locale = locale;
+ Object.keys(modules).forEach((module) => {
+ describe(module, () => {
+ // if there is nothing to test, create a dummy test so the test runner doesn't complain
+ if (Object.keys(modules[module]).length === 0) {
+ it.todo(`${module} was empty`);
+ }
- modules[module].forEach((meth) => {
- it(meth + '()', () => {
- const result = faker[module][meth]();
- if (meth === 'boolean') {
- expect(typeof result).toBe('boolean');
- } else {
- expect(result).toBeTruthy();
- }
+ modules[module].forEach((meth) => {
+ it(meth + '()', () => {
+ const result = faker[module][meth]();
+ if (meth === 'boolean') {
+ expect(typeof result).toBe('boolean');
+ } else {
+ expect(result).toBeTruthy();
+ }
+ });
});
});
});
@@ -79,26 +81,28 @@ describe('functional tests', () => {
describe('faker.fake functional tests', () => {
for (const locale in faker.locales) {
- faker.locale = locale;
- faker.seed(1);
- Object.keys(modules).forEach((module) => {
- describe(module, () => {
- // if there is nothing to test, create a dummy test so the test runner doesn't complain
- if (Object.keys(modules[module]).length === 0) {
- it.todo(`${module} was empty`);
- }
+ describe(locale, () => {
+ faker.locale = locale;
+ faker.seed(1);
+ Object.keys(modules).forEach((module) => {
+ describe(module, () => {
+ // if there is nothing to test, create a dummy test so the test runner doesn't complain
+ if (Object.keys(modules[module]).length === 0) {
+ it.todo(`${module} was empty`);
+ }
- modules[module].forEach((meth) => {
- it(meth + '()', () => {
- const result = faker.fake('{{' + module + '.' + meth + '}}');
- // just make sure any result is returned
- // an undefined result usually means an error
- expect(result).toBeDefined();
- // if (meth === 'boolean') {
- // expect(typeof result).toBe('boolean');
- // } else {
- // expect(result).toBeTruthy();
- // }
+ modules[module].forEach((meth) => {
+ it(meth + '()', () => {
+ const result = faker.fake('{{' + module + '.' + meth + '}}');
+ // just make sure any result is returned
+ // an undefined result usually means an error
+ expect(result).toBeDefined();
+ // if (meth === 'boolean') {
+ // expect(typeof result).toBe('boolean');
+ // } else {
+ // expect(result).toBeTruthy();
+ // }
+ });
});
});
});