Skip to content
This repository has been archived by the owner on Jul 19, 2021. It is now read-only.

Commit

Permalink
Add tests for 'webpack.config.extend.prod' and 'webpack.config.extend…
Browse files Browse the repository at this point in the history
….dev'
  • Loading branch information
t-kelly committed Sep 10, 2018
1 parent ef039d8 commit 6db7b5d
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 4 deletions.
25 changes: 25 additions & 0 deletions packages/slate-tools/tools/webpack/config/__tests__/dev.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
test(`merges contents of 'webpack.config.extend.dev' into webpack config`, () => {
global.slateUserConfig = {
'webpack.config.extend.dev': {some: 'value'},
};

jest.mock('../core', () => {
return {entry: {}};
});
jest.mock('webpack-merge');
jest.mock('../../entrypoints', () => {
return {
templateFiles: jest.fn(),
layoutFiles: jest.fn(),
};
});

const merge = require('webpack-merge');
const config = require('../dev');

expect(merge).toBeCalledWith(
expect.arrayContaining([
global.slateUserConfig['webpack.config.extend.dev'],
]),
);
});
25 changes: 25 additions & 0 deletions packages/slate-tools/tools/webpack/config/__tests__/prod.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
test(`merges contents of 'webpack.config.extend.prod' into webpack config`, () => {
global.slateUserConfig = {
'webpack.config.extend.prod': {some: 'value'},
};

jest.mock('../core', () => {
return {entry: {}};
});
jest.mock('webpack-merge');
jest.mock('../../entrypoints', () => {
return {
templateFiles: jest.fn(),
layoutFiles: jest.fn(),
};
});

const merge = require('webpack-merge');
const config = require('../prod');

expect(merge).toBeCalledWith(
expect.arrayContaining([
global.slateUserConfig['webpack.config.extend.prod'],
]),
);
});
4 changes: 2 additions & 2 deletions packages/slate-tools/tools/webpack/config/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Object.keys(webpackCoreConfig.entry).forEach((name) => {
].concat(webpackCoreConfig.entry[name]);
});

module.exports = merge(
module.exports = merge([
webpackCoreConfig,
babel,
{
Expand Down Expand Up @@ -110,4 +110,4 @@ module.exports = merge(
],
},
config.get('webpack.config.extend.dev'),
);
]);
4 changes: 2 additions & 2 deletions packages/slate-tools/tools/webpack/config/prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const {templateFiles, layoutFiles} = require('../entrypoints');
const HtmlWebpackIncludeLiquidStylesPlugin = require('../html-webpack-include-chunks');
const config = new SlateConfig(require('../../../slate-tools.schema'));

module.exports = merge(
module.exports = merge([
webpackCoreConfig,
babel,
sass,
Expand Down Expand Up @@ -110,4 +110,4 @@ module.exports = merge(
},
},
config.get('webpack.config.extend.prod'),
);
]);

0 comments on commit 6db7b5d

Please sign in to comment.