Permalink
Browse files

Add functional tests for builds and locale-data

  • Loading branch information...
1 parent 709ec34 commit 532c53946aa97dd81e590fc6c00fb9acd3ee20f3 @ericf ericf committed Jan 14, 2016
Showing with 107 additions and 7 deletions.
  1. +10 −0 .babelrc
  2. +1 −0 .eslintignore
  3. +2 −0 .istanbul.yml
  4. +9 −7 package.json
  5. +65 −0 test/functional/builds.js
  6. +20 −0 test/functional/locale-data.js
View
@@ -0,0 +1,10 @@
+{
+ "plugins": [
+ "transform-es2015-modules-commonjs"
+ ],
+ "ignore": [
+ "dist/*.js",
+ "lib/index.js",
+ "locale-data/*.js"
+ ]
+}
View
@@ -1,3 +1,4 @@
+coverage/**/*.js
dist/**/*.js
examples/**/node_modules/**/*.js
examples/**/build/**/*.js
View
@@ -1,4 +1,6 @@
instrumentation:
excludes:
+ - dist/*
+ - lib/*
- locale-data/*
- src/en.js
View
@@ -43,6 +43,7 @@
"babel-cli": "^6.2.0",
"babel-eslint": "^5.0.0-beta4",
"babel-plugin-react-intl": "^2.0.0",
+ "babel-plugin-transform-es2015-modules-commonjs": "^6.4.0",
"babel-plugin-transform-es3-member-expression-literals": "^6.3.13",
"babel-plugin-transform-es3-property-literals": "^6.3.13",
"babel-plugin-transform-object-rest-spread": "^6.1.18",
@@ -82,19 +83,20 @@
"superagent": "^1.5.0"
},
"scripts": {
- "lint": "eslint src/ test/ scripts/ examples/",
"clean": "rimraf src/en.js coverage/ dist/ lib/ locale-data/",
"build:data": "babel-node scripts/build-data",
"build:lib": "babel-node scripts/build-lib",
"build:dist:dev": "NODE_ENV=development babel-node scripts/build-dist",
"build:dist:prod": "NODE_ENV=production babel-node scripts/build-dist",
"build:dist": "npm run build:dist:dev && npm run build:dist:prod",
"build": "npm run build:data && npm run build:lib && npm run build:dist",
- "test:unit": "mocha --compilers js:babel-register --require babel-polyfill --require intl --recursive test/unit/",
- "test:unit:cov": "babel-node $(npm bin)/isparta cover --report text --report html node_modules/mocha/bin/_mocha -- --require babel-polyfill --require intl --recursive test/unit/",
- "test:unit:watch": "npm run test:unit -- --watch --reporter min",
- "test": "npm run test:unit",
- "test:cov": "npm run test:unit:cov",
- "prepublish": "npm run lint && npm run clean && npm run build && npm test"
+ "lint": "eslint .",
+ "test": "mocha --compilers js:babel-register --require babel-polyfill --require intl --recursive test/",
+ "test:cov": "babel-node $(npm bin)/isparta cover --report text --report html node_modules/mocha/bin/_mocha -- --require babel-polyfill --require intl --recursive test/",
+ "test:watch": "npm run test -- --watch --reporter min",
+ "pretest": "npm run lint",
+ "pretest:cov": "npm run lint",
+ "preversion": "npm run clean && npm run build && npm run test",
+ "prepublish": "npm run clean && npm run build"
}
}
@@ -0,0 +1,65 @@
+import expect from 'expect';
+import * as ReactIntl from '../../src/';
+
+const umdDev = '../../dist/react-intl.js';
+const umdProd = '../../dist/react-intl.min.js';
+const cjs = '../../lib/index.js';
+const es = '../../lib/index.es.js';
+
+describe('builds', () => {
+ describe('UMD dev', () => {
+ it('evaluates', () => {
+ expect(require(umdDev)).toExist();
+ });
+
+ it('has all React Intl exports', () => {
+ const ReactIntlUMD = require(umdDev);
+
+ Object.keys(ReactIntl).forEach((name) => {
+ expect(ReactIntlUMD[name]).toBeA(typeof ReactIntl[name]);
+ });
+ });
+ });
+
+ describe('UMD prod', () => {
+ it('evaluates', () => {
+ expect(require(umdProd)).toExist();
+ });
+
+ it('has all React Intl exports', () => {
+ const ReactIntlUMD = require(umdProd);
+
+ Object.keys(ReactIntl).forEach((name) => {
+ expect(ReactIntlUMD[name]).toBeA(typeof ReactIntl[name]);
+ });
+ });
+ });
+
+ describe('CJS', () => {
+ it('evaluates', () => {
+ expect(require(cjs)).toExist();
+ });
+
+ it('has all React Intl exports', () => {
+ const ReactIntlCJS = require(cjs);
+
+ Object.keys(ReactIntl).forEach((name) => {
+ expect(ReactIntlCJS[name]).toBeA(typeof ReactIntl[name]);
+ });
+ });
+ });
+
+ describe('ES', () => {
+ it('evaluates', () => {
+ expect(require(es)).toExist();
+ });
+
+ it('has all React Intl exports', () => {
+ const ReactIntlES = require(es);
+
+ Object.keys(ReactIntl).forEach((name) => {
+ expect(ReactIntlES[name]).toBeA(typeof ReactIntl[name]);
+ });
+ });
+ });
+});
@@ -0,0 +1,20 @@
+import * as p from 'path';
+import expect from 'expect';
+import {sync as globSync} from 'glob';
+
+describe('locale data', () => {
+ it('has generated locale data modules with correct shape', () => {
+ const localeDataFiles = globSync('./locale-data/*.js');
+
+ expect(localeDataFiles.length).toBeGreaterThan(0);
+ localeDataFiles.forEach((filename) => {
+ const localeData = require(p.resolve(filename));
+
+ expect(localeData).toBeAn('array');
+ localeData.forEach((locale) => {
+ expect(locale).toBeAn('object');
+ expect(locale.locale).toExist();
+ });
+ });
+ });
+});

0 comments on commit 532c539

Please sign in to comment.