Skip to content

Commit

Permalink
tests setup
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno12mota committed Jun 9, 2016
1 parent 6570d37 commit 046b31f
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ node_modules

/public/
dist/
.tmp
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ lib/
uploads/
build/
package.json.tmp
.tmp
5 changes: 5 additions & 0 deletions lib/shared/reducers/__tests__/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"env": {
"mocha": true
}
}
12 changes: 12 additions & 0 deletions lib/shared/reducers/__tests__/page-builder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import expect from 'expect';

import pageBuilderReducer from '../page-builder';

describe('Page Builder Reducer', () => {
it('Does not alter state if not a valid action', () => {
const state = {something: 1};
const newState = pageBuilderReducer(state, {type: 'not-valid'});
expect(newState).toBe(state);
expect(newState).toEqual(state);
});
});
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"dev": "parallelshell \"npm run webpackServer\" \"npm run watchServer\"",
"watchServer": "nodemon -e js,jsx,json -w app.js -w lib -i lib/client -x \"webpack --config ./webpack/webpack.node.config.js && npm run startDev\"",
"webpackServer": "webpack-dev-server --config ./webpack/webpack.browser.config.js --inline --hot --quiet --display-error-details",
"lint": "eslint lib/** --quiet"
"lint": "eslint lib/** --quiet",
"test": "cross-env NODE_ENV=test mocha-webpack --colors --webpack-config ./webpack/webpack.test.config \"lib/**/__tests__/*.js\""
},
"dependencies": {
"babel-polyfill": "^6.3.14",
Expand Down Expand Up @@ -106,11 +107,14 @@
"eslint-config-airbnb": "^7.0.0",
"eslint-plugin-jsx-a11y": "^0.6.2",
"eslint-plugin-react": "^4.2.2",
"expect": "^1.20.1",
"extract-text-webpack-plugin": "^0.9.1",
"file-loader": "^0.8.4",
"json-loader": "^0.5.3",
"less": "^2.6.0",
"less-loader": "^2.2.2",
"mocha": "^2.5.3",
"mocha-webpack": "^0.3.1",
"nodemon": "^1.8.1",
"parallelshell": "^2.0.0",
"postcss-loader": "^0.9.1",
Expand All @@ -123,7 +127,8 @@
"url-loader": "^0.5.6",
"webpack": "^1.12.6",
"webpack-dev-server": "^1.12.1",
"webpack-hot-middleware": "^2.5.0"
"webpack-hot-middleware": "^2.5.0",
"webpack-node-externals": "^1.2.0"
},
"apps": [
{
Expand Down
48 changes: 48 additions & 0 deletions webpack/webpack.test.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/* eslint-disable */
var webpack = require('webpack');
var path = require('path');
var nodeExternals = require('webpack-node-externals');
var optimize = webpack.optimize;

var webpackConfig = module.exports = {
target: 'node', // in order to ignore built-in modules like path, fs, etc.
externals: [nodeExternals()], // in order to ignore all modules in node_modules folder
devtool: 'cheap-module-source-map',
resolve: {
modulesDirectories: ['shared', 'node_modules'],
extensions: ['', '.js', '.jsx', '.json']
},
plugins: [
new optimize.OccurenceOrderPlugin()
],
module: {
loaders: [
{
test: /\.(js|jsx)$/,
loader: 'babel',
exclude: /node_modules/,
query: {
cacheDirectory: true,
presets: ['react', 'es2015', 'stage-0'],
plugins: ['transform-decorators-legacy']
}
},
{
test: /\.json$/,
loader: 'json'
},
{
test: /\.(png|jpg|jpeg|gif)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url'
},
{
test: /\.(woff|woff2|ttf|eot|svg)$/,
loader: 'file-loader?name=fonts/[name].[ext]'
},
{
test: /\.(css|less)$/,
loader: 'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!less'
}
]
}
};

0 comments on commit 046b31f

Please sign in to comment.