enable tests on ui

This commit is contained in:
Sérgio Ramos 2016-10-24 12:43:32 +01:00
parent eefaf1d625
commit a9a19e4476
8 changed files with 6309 additions and 37 deletions

View File

@ -10,8 +10,12 @@ test-cloudapi-graphql:
test-frontend:
$(MAKE) -C frontend test
.PHONY: test-ui
test-ui:
$(MAKE) -C ui test
.PHONY: test
test: test-cloudapi-graphql test-frontend
test: test-cloudapi-graphql test-frontend test-ui
.PHONY: install-cloudapi-graphql
install-cloudapi-graphql:

View File

@ -12,5 +12,15 @@
["transform-object-rest-spread", {
"useBuiltIns": true
}]
]
],
"env": {
"test": {
"plugins": [
["babel-plugin-webpack-loaders", {
"config": "${CONFIG}",
"verbose": true
}]
]
}
}
}

7
ui/Makefile Normal file
View File

@ -0,0 +1,7 @@
.PHONY: test
test:
yarn run test
.PHONY: install
install:
yarn

View File

@ -6,7 +6,7 @@
"scripts": {
"start": "webpack-dev-server --open --config webpack/index.js",
"lint": "eslint .",
"test": "NODE_ENV=test nyc ava test/*.js --verbose",
"test": "BABEL_DISABLE_CACHE=1 NODE_ENV=test CONFIG=$(pwd)/webpack/index.js nyc ava test/*.js --verbose",
"build": "NODE_ENV=production webpack --config webpack/index.js",
"clean-static": "sh scripts/clean-static.sh",
"build-docs-static": "sh scripts/build-docs-static.sh"
@ -22,6 +22,7 @@
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-syntax-async-functions": "^6.13.0",
"babel-plugin-transform-object-rest-spread": "^6.16.0",
"babel-plugin-webpack-loaders": "^0.8.0",
"babel-preset-es2015": "^6.16.0",
"babel-preset-react": "^6.16.0",
"babel-register": "^6.16.3",

View File

@ -6,20 +6,8 @@ const {
shallow
} = enzyme;
test('renders <App> without exploding', (t) => {
const App = require('../src/containers/app');
const wrapper = shallow(<App />);
t.deepEqual(wrapper.length, 1);
});
test('renders <Home> without exploding', (t) => {
const Home = require('../src/containers/home');
const wrapper = shallow(<Home />);
t.deepEqual(wrapper.length, 1);
});
test('renders <NotFound> without exploding', (t) => {
const NotFound = require('../src/containers/not-found');
const wrapper = shallow(<NotFound />);
test('renders <Button> without exploding', (t) => {
const Button = require('../src/button');
const wrapper = shallow(<Button />);
t.deepEqual(wrapper.length, 1);
});

View File

@ -2,6 +2,29 @@ const ExtractTextPlugin = require('extract-text-webpack-plugin');
const webpack = require('webpack');
const path = require('path');
const plugins = {
'no-errors-plugin': new webpack.NoErrorsPlugin(),
'extract-text-plugin': new ExtractTextPlugin({
filename: '[name].css',
allChunks: true
}),
'loader-options-plugin': new webpack.LoaderOptionsPlugin({
options: {
postcss: {
plugins: () => {
return [
require('postcss-cssnext')
];
}
},
'embed-markdown-loader': {
// don't detach yet (has a bug in the production config)
// webpackConfigFullpath: path.join(__dirname, 'index.js')
}
}
})
};
module.exports = {
context: path.join(__dirname, '../'),
output: {
@ -10,25 +33,9 @@ module.exports = {
filename: '[name].js'
},
plugins: [
new webpack.NoErrorsPlugin(),
new ExtractTextPlugin({
filename: '[name].css',
allChunks: true
}),
new webpack.LoaderOptionsPlugin({
options: {
postcss: {
plugins: () => {
return [
require('postcss-cssnext')
];
}
},
'embed-markdown-loader': {
// webpackConfigFullpath: path.join(__dirname, 'index.js') don't detach yet (has a bug in the production config)
}
}
})
plugins['no-errors-plugin'],
plugins['extract-text-plugin'],
plugins['loader-options-plugin']
],
resolveLoader: {
alias: {
@ -74,3 +81,5 @@ module.exports = {
}]
}
};
module.exports.__plugins = plugins;

19
ui/webpack/test.js Normal file
View File

@ -0,0 +1,19 @@
const config = require('./config');
const webpack = require('webpack');
const path = require('path');
module.exports = {
output: {
libraryTarget: 'commonjs2'
},
plugins: [
config.__plugins['no-errors-plugin'],
config.__plugins['loader-options-plugin']
],
module: {
loaders: [{
test: /\.css?$/,
loader: 'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss-loader'
}]
}
};

6234
ui/yarn.lock Normal file

File diff suppressed because it is too large Load Diff