Skip to content

Commit 2a46167

Browse files
machourHoussein Djirdeh
authored andcommitted
test: make locale test output more readable (#712)
* test: make locale test output more readable * refactor: nuke useless variable
1 parent 3d793a5 commit 2a46167

File tree

3 files changed

+79
-47
lines changed

3 files changed

+79
-47
lines changed

__tests__/tests/others/locales.js

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,17 @@
11
import { common } from 'config';
2+
import keysDiff from 'keys-diff';
23
import * as languages from 'locale/languages';
34

4-
function createExpectedObject(object) {
5-
const ret = {};
6-
7-
Object.keys(object).forEach(key => {
8-
ret[key] =
9-
typeof object[key] === 'object'
10-
? createExpectedObject(object[key])
11-
: expect.stringMatching(/./);
12-
});
13-
14-
return ret;
15-
}
16-
175
const baseLanguage = common.defaultLocale;
18-
const expectedObject = createExpectedObject(languages[baseLanguage]);
196

207
describe('Locales', () => {
218
Object.keys(languages).forEach(key => {
229
if (key === baseLanguage) return;
23-
2410
it(`${key} should contain same keys as ${baseLanguage}`, () => {
25-
expect(languages[key]).toMatchObject(expectedObject);
11+
expect(keysDiff(languages[baseLanguage], languages[key])).toEqual([
12+
[],
13+
[],
14+
]);
2615
});
2716
});
2817
});

package.json

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,13 @@
66
"start": "react-native start",
77
"start:logger": "LOGGER_ENABLED=true react-native start --reset-cache",
88
"start:tron": "TRON_ENABLED=true react-native start --reset-cache",
9-
"start:android":
10-
"concurrently -r 'react-native start' 'yarn start:android:no-packager'",
11-
"start:android:logger":
12-
"LOGGER_ENABLED=true concurrently -r 'react-native start --reset-cache' 'yarn start:android:no-packager'",
13-
"start:android:tron":
14-
"TRON_ENABLED=true concurrently -r 'react-native start --reset-cache' 'yarn start:android:no-packager'",
9+
"start:android": "concurrently -r 'react-native start' 'yarn start:android:no-packager'",
10+
"start:android:logger": "LOGGER_ENABLED=true concurrently -r 'react-native start --reset-cache' 'yarn start:android:no-packager'",
11+
"start:android:tron": "TRON_ENABLED=true concurrently -r 'react-native start --reset-cache' 'yarn start:android:no-packager'",
1512
"start:android:no-packager": "react-native run-android --no-packager",
16-
"start:ios":
17-
"concurrently -r 'react-native start' 'yarn start:ios:no-packager'",
18-
"start:ios:logger":
19-
"LOGGER_ENABLED=true concurrently -r 'react-native start --reset-cache' 'yarn start:ios:no-packager'",
20-
"start:ios:tron":
21-
"TRON_ENABLED=true concurrently -r 'react-native start --reset-cache' 'yarn start:ios:no-packager'",
13+
"start:ios": "concurrently -r 'react-native start' 'yarn start:ios:no-packager'",
14+
"start:ios:logger": "LOGGER_ENABLED=true concurrently -r 'react-native start --reset-cache' 'yarn start:ios:no-packager'",
15+
"start:ios:tron": "TRON_ENABLED=true concurrently -r 'react-native start --reset-cache' 'yarn start:ios:no-packager'",
2216
"start:ios:no-packager": "react-native run-ios --no-packager",
2317
"clean": "rm -rf node_modules",
2418
"clean:android": "cd android && ./gradlew clean && cd -",
@@ -42,21 +36,20 @@
4236
"cp-release:ios": "code-push release-react git-point-ios ios",
4337
"cp-release:android": "code-push release-react git-point-android android",
4438
"cp-promote:ios": "code-push promote git-point-ios Staging Production",
45-
"cp-promote:android":
46-
"code-push promote git-point-android Staging Production",
47-
"cp-history:ios-staging":
48-
"code-push deployment history git-point-ios Staging",
49-
"cp-history:android-staging":
50-
"code-push deployment history git-point-android Staging",
51-
"cp-history:android-production":
52-
"code-push deployment history git-point-android Production",
53-
"cp-history:ios-production":
54-
"code-push deployment history git-point-ios Production",
39+
"cp-promote:android": "code-push promote git-point-android Staging Production",
40+
"cp-history:ios-staging": "code-push deployment history git-point-ios Staging",
41+
"cp-history:android-staging": "code-push deployment history git-point-android Staging",
42+
"cp-history:android-production": "code-push deployment history git-point-android Production",
43+
"cp-history:ios-production": "code-push deployment history git-point-ios Production",
5544
"doctoc": "doctoc --title='## Table of Contents' README.md",
5645
"postinstall": "opencollective postinstall"
5746
},
5847
"lint-staged": {
59-
"*.js": ["prettier --write", "git add", "eslint --cache"]
48+
"*.js": [
49+
"prettier --write",
50+
"git add",
51+
"eslint --cache"
52+
]
6053
},
6154
"dependencies": {
6255
"date-fns": "^1.29.0",
@@ -85,8 +78,7 @@
8578
"react-native-i18n": "^2.0.4",
8679
"react-native-linear-gradient": "^2.4.0",
8780
"react-native-material-design-searchbar": "^1.1.4",
88-
"react-native-mock":
89-
"https://github.com/shqld/react-native-mock/tarball/master",
81+
"react-native-mock": "https://github.com/shqld/react-native-mock/tarball/master",
9082
"react-native-parallax-scroll-view": "^0.20.1",
9183
"react-native-photo-view": "^1.5.2",
9284
"react-native-safari-view": "^2.0.0",
@@ -133,6 +125,7 @@
133125
"flow-bin": "^0.47.0",
134126
"husky": "^0.14.3",
135127
"jest": "^21.2.1",
128+
"keys-diff": "^1.0.5",
136129
"lint-staged": "^3.2.6",
137130
"minicat": "^1.0.0",
138131
"prettier": "^1.7.4",
@@ -148,18 +141,23 @@
148141
},
149142
"jest": {
150143
"preset": "react-native",
151-
"testMatch": ["**/__tests__/tests/**/*.js"],
152-
"setupFiles": ["./testenv.js"],
144+
"testMatch": [
145+
"**/__tests__/tests/**/*.js"
146+
],
147+
"setupFiles": [
148+
"./testenv.js"
149+
],
153150
"transformIgnorePatterns": [
154151
"node_modules/(?!(jest-)?react-native|react-navigation)"
155152
],
156153
"moduleNameMapper": {
157-
"styled-components":
158-
"<rootDir>/node_modules/styled-components/dist/styled-components.native.cjs.js"
154+
"styled-components": "<rootDir>/node_modules/styled-components/dist/styled-components.native.cjs.js"
159155
}
160156
},
161157
"rnpm": {
162-
"assets": ["./src/assets/fonts"]
158+
"assets": [
159+
"./src/assets/fonts"
160+
]
163161
},
164162
"config": {
165163
"commitizen": {

yarn.lock

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,10 @@ argparse@^1.0.7:
255255
dependencies:
256256
sprintf-js "~1.0.2"
257257

258+
argv@>=0.0.2:
259+
version "0.0.2"
260+
resolved "https://registry.yarnpkg.com/argv/-/argv-0.0.2.tgz#ecbd16f8949b157183711b1bda334f37840185ab"
261+
258262
aria-query@^0.7.0:
259263
version "0.7.0"
260264
resolved "https://registry.yarnpkg.com/aria-query/-/aria-query-0.7.0.tgz#4af10a1e61573ddea0cf3b99b51c52c05b424d24"
@@ -1663,6 +1667,15 @@ code-push@2.0.4:
16631667
superagent-proxy "^1.0.0"
16641668
yazl "^2.4.1"
16651669

1670+
codecov@^1.0.1:
1671+
version "1.0.1"
1672+
resolved "https://registry.yarnpkg.com/codecov/-/codecov-1.0.1.tgz#97260ceac0e96b8eda8d562006558a53a139dffd"
1673+
dependencies:
1674+
argv ">=0.0.2"
1675+
execSync "1.0.2"
1676+
request ">=2.42.0"
1677+
urlgrey ">=0.4.0"
1678+
16661679
collapse-white-space@^1.0.0, collapse-white-space@^1.0.2:
16671680
version "1.0.3"
16681681
resolved "https://registry.yarnpkg.com/collapse-white-space/-/collapse-white-space-1.0.3.tgz#4b906f670e5a963a87b76b0e1689643341b6023c"
@@ -2746,6 +2759,12 @@ exec-sh@^0.2.0:
27462759
dependencies:
27472760
merge "^1.1.3"
27482761

2762+
execSync@1.0.2:
2763+
version "1.0.2"
2764+
resolved "https://registry.yarnpkg.com/execSync/-/execSync-1.0.2.tgz#1f42eda582225180053224ecdd3fd1960fdb3139"
2765+
dependencies:
2766+
temp "~0.5.1"
2767+
27492768
execa@^0.7.0:
27502769
version "0.7.0"
27512770
resolved "https://registry.yarnpkg.com/execa/-/execa-0.7.0.tgz#944becd34cc41ee32a63a9faf27ad5a65fc59777"
@@ -3291,6 +3310,10 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.3, graceful-fs@^4.1.4,
32913310
version "4.1.11"
32923311
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"
32933312

3313+
graceful-fs@~1:
3314+
version "1.2.3"
3315+
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-1.2.3.tgz#15a4806a57547cb2d2dbf27f42e89a8c3451b364"
3316+
32943317
growly@^1.3.0:
32953318
version "1.3.0"
32963319
resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081"
@@ -4432,6 +4455,12 @@ keymirror@^0.1.1:
44324455
version "0.1.1"
44334456
resolved "https://registry.yarnpkg.com/keymirror/-/keymirror-0.1.1.tgz#918889ea13f8d0a42e7c557250eee713adc95c35"
44344457

4458+
keys-diff@^1.0.5:
4459+
version "1.0.5"
4460+
resolved "https://registry.yarnpkg.com/keys-diff/-/keys-diff-1.0.5.tgz#b6539a5021681101d19f94d71e40d74bff24c18c"
4461+
dependencies:
4462+
codecov "^1.0.1"
4463+
44354464
kind-of@^3.0.2:
44364465
version "3.2.2"
44374466
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64"
@@ -6759,7 +6788,7 @@ request@2.81.0:
67596788
tunnel-agent "^0.6.0"
67606789
uuid "^3.0.0"
67616790

6762-
request@^2.72.0, request@^2.79.0:
6791+
request@>=2.42.0, request@^2.72.0, request@^2.79.0:
67636792
version "2.83.0"
67646793
resolved "https://registry.yarnpkg.com/request/-/request-2.83.0.tgz#ca0b65da02ed62935887808e6f510381034e3356"
67656794
dependencies:
@@ -6880,6 +6909,12 @@ rimraf@2, rimraf@2.x.x, rimraf@^2.2.8, rimraf@^2.5.1, rimraf@^2.5.4, rimraf@^2.6
68806909
dependencies:
68816910
glob "^7.0.5"
68826911

6912+
rimraf@~2.1.4:
6913+
version "2.1.4"
6914+
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.1.4.tgz#5a6eb62eeda068f51ede50f29b3e5cd22f3d9bb2"
6915+
optionalDependencies:
6916+
graceful-fs "~1"
6917+
68836918
rimraf@~2.2.6:
68846919
version "2.2.8"
68856920
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.2.8.tgz#e439be2aaee327321952730f99a8929e4fc50582"
@@ -7609,6 +7644,12 @@ temp@0.8.3:
76097644
os-tmpdir "^1.0.0"
76107645
rimraf "~2.2.6"
76117646

7647+
temp@~0.5.1:
7648+
version "0.5.1"
7649+
resolved "https://registry.yarnpkg.com/temp/-/temp-0.5.1.tgz#77ab19c79aa7b593cbe4fac2441768cad987b8df"
7650+
dependencies:
7651+
rimraf "~2.1.4"
7652+
76127653
test-exclude@^4.1.1:
76137654
version "4.1.1"
76147655
resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-4.1.1.tgz#4d84964b0966b0087ecc334a2ce002d3d9341e26"
@@ -7906,6 +7947,10 @@ update-section@^0.3.0:
79067947
version "0.3.3"
79077948
resolved "https://registry.yarnpkg.com/update-section/-/update-section-0.3.3.tgz#458f17820d37820dc60e20b86d94391b00123158"
79087949

7950+
urlgrey@>=0.4.0:
7951+
version "0.4.4"
7952+
resolved "https://registry.yarnpkg.com/urlgrey/-/urlgrey-0.4.4.tgz#892fe95960805e85519f1cd4389f2cb4cbb7652f"
7953+
79097954
user-home@^1.1.1:
79107955
version "1.1.1"
79117956
resolved "https://registry.yarnpkg.com/user-home/-/user-home-1.1.1.tgz#2b5be23a32b63a7c9deb8d0f28d485724a3df190"

0 commit comments

Comments
 (0)