Fix test suite (i18n) // Make sure that nodes uses full icu (#2946)

This commit is contained in:
William Durand 2017-08-18 12:55:56 +02:00 коммит произвёл GitHub
Родитель c0147fe7f1
Коммит 4e355b6a08
4 изменённых файлов: 43 добавлений и 13 удалений

0
bin/version-check.js Normal file → Executable file
Просмотреть файл

Просмотреть файл

@ -25,20 +25,21 @@
"flow:dev": "flow stop; flow start; chokidar .flowconfig flow/ src/ tests/ -i flow/logs/flow.log -c 'flow status' --initial",
"stylelint": "stylelint --syntax scss **/*.scss",
"lint": "npm run eslint && npm run stylelint",
"start": "npm run version-check && NODE_PATH='./:./src' node bin/server.js",
"start-func-test-server": "node bin/start-func-test-server.js",
"start": "npm run version-check && better-npm-run node bin/server.js",
"start-func-test-server": "better-npm-run node bin/start-func-test-server.js",
"test-ci": "bin/config-check.js && better-npm-run test-ci && cat ./coverage/lcov.info | coveralls",
"test": "bin/config-check.js && jest --watch",
"test-coverage": "bin/config-check.js && jest --coverage --watch",
"test-coverage-once": "bin/config-check.js && jest --coverage",
"test-once": "bin/config-check.js && jest && npm run lint",
"version-check": "node bin/version-check.js",
"test": "bin/config-check.js && better-npm-run jest --watch",
"test-coverage": "bin/config-check.js && better-npm-run jest --coverage --watch",
"test-coverage-once": "bin/config-check.js && better-npm-run jest --coverage",
"test-once": "bin/config-check.js && better-npm-run jest && npm run lint",
"version-check": "bin/version-check.js",
"webpack-dev-server": "npm run build-locales && better-npm-run webpack-dev-server"
},
"betterScripts": {
"build": {
"command": "npm run clean && npm run version-check && npm run build-locales && webpack --bail --verbose --display-error-details --progress --colors --config webpack.prod.config.babel.js",
"env": {
"NODE_ICU_DATA": "./node_modules/full-icu",
"NODE_PATH": "./:./src"
}
},
@ -82,8 +83,9 @@
"extract-locales": {
"command": "webpack --verbose --bail --display-error-details --progress --colors --config webpack.l10n.config.babel.js",
"env": {
"NODE_PATH": "./:./src",
"NODE_ENV": "production"
"NODE_ENV": "production",
"NODE_ICU_DATA": "./node_modules/full-icu",
"NODE_PATH": "./:./src"
}
},
"start-dev": {
@ -91,6 +93,7 @@
"env": {
"ENABLE_PIPING": "true",
"NODE_ENV": "development",
"NODE_ICU_DATA": "./node_modules/full-icu",
"NODE_PATH": "./:./src"
}
},
@ -99,13 +102,28 @@
"env": {
"ENABLE_PIPING": "true",
"NODE_ENV": "development",
"NODE_ICU_DATA": "./node_modules/full-icu",
"NODE_PATH": "./:./src",
"SERVER_PORT": "3333"
}
},
"node": {
"command": "node",
"env": {
"NODE_ICU_DATA": "./node_modules/full-icu",
"NODE_PATH": "./:./src"
}
},
"jest": {
"command": "jest",
"env": {
"NODE_ICU_DATA": "./node_modules/full-icu"
}
},
"test-ci": {
"command": "npm run version-check && npm run flow:check && npm run test-coverage-once",
"env": {
"NODE_ICU_DATA": "./node_modules/full-icu",
"NODE_PATH": "./:./src",
"NODE_ENV": "test"
}
@ -114,6 +132,7 @@
"command": "node bin/webpack-dev-server.js",
"env": {
"NODE_ENV": "development",
"NODE_ICU_DATA": "./node_modules/full-icu",
"NODE_PATH": "./:./src"
}
}
@ -143,6 +162,7 @@
"express": "4.15.2",
"extract-text-webpack-plugin": "3.0.0",
"fastclick": "1.0.6",
"full-icu": "1.2.0",
"helmet": "3.8.1",
"humps": "2.0.1",
"isomorphic-fetch": "2.2.1",

Просмотреть файл

@ -460,8 +460,8 @@ describe('i18n utils', () => {
const numberFormatSpy = sinon.spy(Intl, 'NumberFormat');
const i18n = utils.makeI18n({}, 'de', FakeJed, { _Intl: false });
const toLocaleStringSpy = sinon.spy(Number.prototype, 'toLocaleString');
const number = 1234;
expect(i18n.formatNumber(number)).toEqual('1,234');
const number = 9518231;
expect(i18n.formatNumber(number)).toEqual('9.518.231');
sinon.assert.calledWith(toLocaleStringSpy, 'de');
sinon.assert.notCalled(numberFormatSpy);
});
@ -471,7 +471,7 @@ describe('i18n utils', () => {
const i18n = utils.makeI18n({}, 'fr', FakeJed, { _Intl: {} });
const toLocaleStringSpy = sinon.spy(Number.prototype, 'toLocaleString');
const number = 12345;
expect(i18n.formatNumber(number)).toEqual('12,345');
expect(i18n.formatNumber(number)).toEqual('12 345');
sinon.assert.calledWith(toLocaleStringSpy, 'fr');
sinon.assert.notCalled(numberFormatSpy);
});

Просмотреть файл

@ -3303,6 +3303,10 @@ fstream@^1.0.0, fstream@^1.0.10, fstream@^1.0.2:
mkdirp ">=0.5 0"
rimraf "2"
full-icu@1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/full-icu/-/full-icu-1.2.0.tgz#6bd8bf565f696aab30df503de2d47b92d9f1046f"
function-bind@^1.0.2, function-bind@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.0.tgz#16176714c801798e4e8f2cf7f7529467bb4a5771"
@ -5623,7 +5627,7 @@ os-locale@^2.0.0:
lcid "^1.0.0"
mem "^1.1.0"
os-tmpdir@^1.0.0, os-tmpdir@^1.0.1, os-tmpdir@~1.0.1:
os-tmpdir@^1.0.0, os-tmpdir@^1.0.1, os-tmpdir@~1.0.1, os-tmpdir@~1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274"
@ -7952,6 +7956,12 @@ tmp@^0.0.31:
dependencies:
os-tmpdir "~1.0.1"
tmp@^0.0.33:
version "0.0.33"
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9"
dependencies:
os-tmpdir "~1.0.2"
tmpl@1.0.x:
version "1.0.4"
resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.4.tgz#23640dd7b42d00433911140820e5cf440e521dd1"