Skip to content

Commit

Permalink
test: fix failing tests due to refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
swashata committed Oct 8, 2018
1 parent 5786ddb commit 3f508b8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
15 changes: 11 additions & 4 deletions packages/scripts/__tests__/config/WebpackConfigHelper.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function getConfigFromProjectAndServer(
sCfg: ServerConfig
): WebpackConfigHelperConfig {
return {
appName: pCfg.appName,
type: pCfg.type,
slug: pCfg.slug,
host: sCfg.host,
Expand All @@ -27,6 +28,12 @@ function getConfigFromProjectAndServer(
bannerConfig: pCfg.bannerConfig,
alias: pCfg.alias,
optimizeSplitChunks: pCfg.optimizeSplitChunks,
publicPath: `/wp-content/${pCfg.type}s/${pCfg.slug}/${
pCfg.outputPath
}/`,
serverUrl: `//localhost/wp-content/${pCfg.type}s/${pCfg.slug}/${
pCfg.outputPath
}/`,
};
}

Expand All @@ -40,7 +47,6 @@ beforeEach(() => {
{
name: 'config1',
entry: { foo: 'bar.js', biz: ['baz.js'] },
filename: '[name].js',
},
],
};
Expand Down Expand Up @@ -104,7 +110,8 @@ describe('CreateWebPackConfig', () => {
false
);
const output = cwc.getOutput();
expect(output.path).toMatch(/\/config1$/);
expect(output.path).toMatch(/\/dist$/);
expect(output.filename).toBe('config1/[name].js');
});
test('has empty publicPath on production build', () => {
const cwc = new WebpackConfigHelper(
Expand All @@ -124,7 +131,7 @@ describe('CreateWebPackConfig', () => {
true
);
const devOutput = devCwc.getOutput();
expect(devOutput.publicPath).toMatch(/^\/\/(.*)\/config1\/$/);
expect(devOutput.publicPath).toMatch(/^\/\/(.*)\/dist\/$/);
});
test('respects type for constructing publicPath on dev server', () => {
const devCwc = new WebpackConfigHelper(
Expand All @@ -135,7 +142,7 @@ describe('CreateWebPackConfig', () => {
);
const devOutput = devCwc.getOutput();
expect(devOutput.publicPath).toMatch(
/^\/\/(.*)\/wp-content\/plugins\/(.*)\/config1\/$/
/^\/\/(.*)\/wp-content\/plugins\/(.*)\/dist\/$/
);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Object {
"loader": "file-loader",
"options": Object {
"name": "asset-[hash].[ext]",
"outputPath": "assets/",
"outputPath": "config1/assets/",
},
},
],
Expand Down Expand Up @@ -130,13 +130,13 @@ Array [
"verbose": false,
},
"paths": Array [
"/foo/bar/dist/config1",
"/foo/bar/dist",
],
},
MiniCssExtractPlugin {
"options": Object {
"chunkFilename": "[name].css",
"filename": "[name].css",
"chunkFilename": "config1/[name].css",
"filename": "config1/[name].css",
},
},
Object {},
Expand All @@ -157,8 +157,7 @@ This software is released under the GPL-3.0 License
https://opensource.org/licenses/GPL-3.0
Compiled with the help of https://wpack.io
A zero setup Webpack Bundler Script for WordPress
",
A zero setup Webpack Bundler Script for WordPress",
"entryOnly": false,
"include": /\\\\\\.\\(\\(t\\|j\\)sx\\?\\|s\\?\\(c\\|a\\)ss\\)\\$/,
"raw": false,
Expand All @@ -183,13 +182,13 @@ Array [
"verbose": false,
},
"paths": Array [
"/foo/bar/dist/config1",
"/foo/bar/dist",
],
},
MiniCssExtractPlugin {
"options": Object {
"chunkFilename": "[name].css",
"filename": "[name].css",
"chunkFilename": "config1/[name].css",
"filename": "config1/[name].css",
},
},
Object {},
Expand Down

0 comments on commit 3f508b8

Please sign in to comment.