Skip to content

Commit

Permalink
refactor(test): configureLoaderRule() will be easier to test
Browse files Browse the repository at this point in the history
  • Loading branch information
Kocal committed Mar 1, 2019
1 parent 39cb9bd commit 86dc788
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions test/config-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -1016,18 +1016,26 @@ describe('The config-generator function', () => {
});

describe('Test configureLoaderRule()', () => {
it('configure rule for "eslint"', () => {
const config = createConfig();
let config;

const getLoader = (loaderName) => {
const webpackConfig = configGenerator(config);
return webpackConfig.module.rules.find(rule => rule.loader === loaderName);
};

beforeEach(() => {
config = createConfig();
config.outputPath = '/tmp/public/build';
config.setPublicPath('/');
});

it('configure rule for "eslint"', () => {
config.enableEslintLoader();
config.configureLoaderRule('eslint', (loader) => {
loader.test = /\.(jsx?|vue)/;
});

const webpackConfig = configGenerator(config);
const eslintLoader = webpackConfig.module.rules.find(rule => rule.loader === 'eslint-loader');

expect(eslintLoader).to.deep.equals({
expect(getLoader('eslint-loader')).to.deep.equals({
test: /\.(jsx?|vue)/,
enforce: 'pre',
exclude: /node_modules/,
Expand Down

0 comments on commit 86dc788

Please sign in to comment.