Skip to content

Commit

Permalink
Improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksandr Kryzhanovskyy committed Nov 9, 2017
1 parent 7a42429 commit 6a9aacc
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 15 deletions.
4 changes: 4 additions & 0 deletions .gulpenvrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
{
"name": "local",
"aliases": []
},
{
"name": "test",
"aliases": []
}
],

Expand Down
8 changes: 4 additions & 4 deletions app/scripts/shared/date/date.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ describe('DateService', () => {

describe('when format Date', () => {
it('should return date in correct format', () => {
let date= dateService.formatDate('01','01','2018');
let date = dateService.formatDate('01', '01', '2018');
expect(date).to.equal('01/01/2018');
})
});

it('should return empty string if some of parameters is false', () => {
let date= dateService.formatDate(null,'01','2018');
let date = dateService.formatDate(null, '01', '2018');
expect(date).to.equal('');
})
});
});
});
4 changes: 4 additions & 0 deletions mocha-webpack.opts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
--webpack-config webpack.config.js
--webpack-env.NODE_ENV=test
--require jsdom-global/register
app/scripts/**/*.spec.ts
3 changes: 0 additions & 3 deletions mocha.opts

This file was deleted.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "MIT",
"version": "2.1.2",
"scripts": {
"test": "mocha --opts mocha.opts",
"test": "mocha-webpack",
"preprod": "gulp --env=production",
"prod": "webpack --env.NODE_ENV=production",
"postprod": "rimraf ./dist/css/scripts",
Expand Down Expand Up @@ -55,7 +55,10 @@
"gulp-sass-lint": "1.3.2",
"gulp-sourcemaps": "1.9.1",
"gulp-uglify": "2.0.0",
"jsdom": "11.3.0",
"jsdom-global": "3.0.2",
"mocha": "^4.0.1",
"mocha-webpack": "1.0.1",
"opn": "4.0.2",
"require.all": "2.0.3",
"style-loader": "0.18.2",
Expand Down
26 changes: 19 additions & 7 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,24 @@ module.exports = env => {

rules((name, rule) => rule(environment, environments));

// Define global plugins
let plugins = [

];

// Add non-test environment plugins
const testPlugins = [
new webpack.DefinePlugin({
'global': {}
}),
// extract vendor as a separate bundle
new webpack.optimize.CommonsChunkPlugin({ name: 'vendor', filename: 'vendor.js' }),
];

if (environment !== environments.test) {
plugins = [...plugins, ...testPlugins];
}

return ({
entry: {
app: _.files(paths.app.scripts.app),
Expand Down Expand Up @@ -40,13 +58,7 @@ module.exports = env => {
'vue$': 'vue/dist/vue.runtime.common.js'
}
},
plugins: [
new webpack.DefinePlugin({
'global': {}
}),
// extract vendor as a separate bundle
new webpack.optimize.CommonsChunkPlugin({ name: 'vendor', filename: 'vendor.js' }),
],
plugins: plugins,
devtool: (() => environment === environments.production ? false : 'inline-source-map')()
})
};

0 comments on commit 6a9aacc

Please sign in to comment.