Skip to content

Commit

Permalink
test(webpack): add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Cameron J Roe committed Sep 6, 2016
1 parent e5fceb6 commit ef9e21f
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
Empty file.
13 changes: 13 additions & 0 deletions test/fixtures/webpack/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import path from 'path'
import webpack from 'webpack'

export default {
entry: path.resolve(__dirname, './src/assets/js/index.js'),
output: {
path: path.resolve(__dirname, './dist/assets/js'),
filename: 'bundle.js'
},
module: {
loaders: []
}
};
56 changes: 56 additions & 0 deletions test/webpack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import path from 'path';
import configureWebpack from '../src/config/configure-webpack';
import createDefaults from '../src/config/defaults';
import {
expect
} from 'chai';

describe('webpack config', () => {

it('should override module.loaders completely', function(done) {
var config = configureWebpack({
basePath: path.resolve(__dirname, './fixtures/webpack'),
webpack: {
dev: './webpack.config.js',
prod: './webpack.config.js'
}
})
expect(config.dev.module.loaders).to.have.lengthOf(0)
done();
});

it('should keep original module.loaders in tact', function(done) {
var config = configureWebpack({
basePath: path.resolve(__dirname, './fixtures/webpack'),
bower: true,
jquery: true
})
expect(config.dev.module.loaders).to.have.lengthOf(4)
done();
});

it('should create correct defaults without loaders', function(done) {
var defaults = createDefaults({
basePath: path.resolve(__dirname, './fixtures/webpack'),
bower: true,
jquery: true,
webpack: {
dev: './webpack.config.js',
prod: './webpack.config.js'
}
})
expect(defaults.webpack.dev.module.loaders).to.have.lengthOf(0)
done();
});

it('should create correct defaults with default loaders', function(done) {
var defaults = createDefaults({
basePath: path.resolve(__dirname, './fixtures/webpack'),
bower: true,
jquery: true
})
expect(defaults.webpack.dev.module.loaders).to.have.lengthOf(4);
done();
});

})

0 comments on commit ef9e21f

Please sign in to comment.