Skip to content

Commit

Permalink
chore(cr): move tests into
Browse files Browse the repository at this point in the history
  • Loading branch information
Kocal committed Mar 1, 2019
1 parent bc0e9bf commit 39cb9bd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 27 deletions.
26 changes: 26 additions & 0 deletions test/config-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -1014,4 +1014,30 @@ describe('The config-generator function', () => {
});
});
});

describe('Test configureLoaderRule()', () => {
it('configure rule for "eslint"', () => {
const config = createConfig();
config.setPublicPath('/');
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({
test: /\.(jsx?|vue)/,
enforce: 'pre',
exclude: /node_modules/,
loader: 'eslint-loader',
options: {
cache: true,
emitWarning: true,
parser: 'babel-eslint'
}
});
});
});
});
27 changes: 0 additions & 27 deletions test/loaders/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
const expect = require('chai').expect;
const WebpackConfig = require('../../lib/WebpackConfig');
const RuntimeConfig = require('../../lib/config/RuntimeConfig');
const configGenerator = require('../../lib/config-generator');
const eslintLoader = require('../../lib/loaders/eslint');
const isWindows = (process.platform === 'win32');

function createConfig() {
const runtimeConfig = new RuntimeConfig();
Expand Down Expand Up @@ -79,29 +77,4 @@ describe('loaders/eslint', () => {
const actualOptions = eslintLoader.getOptions(config);
expect(actualOptions).to.deep.equals({ foo: true });
});

it('configure ESLint loader rule', () => {
const config = createConfig();
config.outputPath = isWindows ? 'C:\\tmp\\public' : '/tmp/public';
config.setPublicPath('/');
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({
test: /\.(jsx?|vue)/,
enforce: 'pre',
exclude: /node_modules/,
loader: 'eslint-loader',
options: {
cache: true,
emitWarning: true,
parser: 'babel-eslint'
}
});
});
});

0 comments on commit 39cb9bd

Please sign in to comment.