Skip to content

Commit

Permalink
test: rephrase test metadata (#2411)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgeorge007 authored Jan 30, 2020
1 parent ba2993f commit d14892a
Showing 1 changed file with 20 additions and 23 deletions.
43 changes: 20 additions & 23 deletions test/server/utils/addEntries.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const configEntryAsFunction = require('./../../fixtures/entry-as-function/webpac
const normalize = (entry) => entry.split(path.sep).join('/');

describe('addEntries util', () => {
it('should adds devServer entry points to a single entry point', () => {
it('should add devServer entry points to a single entry point', () => {
const webpackOptions = Object.assign({}, config);

addEntries(webpackOptions, {});
Expand All @@ -21,7 +21,7 @@ describe('addEntries util', () => {
expect(normalize(webpackOptions.entry[1])).toEqual('./foo.js');
});

it('should adds devServer entry points to a multi-module entry point', () => {
it('should add devServer entry points to a multi-module entry point', () => {
const webpackOptions = Object.assign({}, config, {
entry: ['./foo.js', './bar.js'],
});
Expand All @@ -36,7 +36,7 @@ describe('addEntries util', () => {
expect(webpackOptions.entry[2]).toEqual('./bar.js');
});

it('should adds devServer entry points to a multi entry point object', () => {
it('should add devServer entry points to a multi entry point object', () => {
const webpackOptions = Object.assign({}, config, {
entry: {
foo: './foo.js',
Expand Down Expand Up @@ -64,7 +64,7 @@ describe('addEntries util', () => {
expect(webpackOptions.entry[1]).toEqual('./src');
});

it('should preserves dynamic entry points', async () => {
it('should preserve dynamic entry points', async () => {
let i = 0;
const webpackOptions = {
// simulate dynamic entry
Expand Down Expand Up @@ -92,7 +92,7 @@ describe('addEntries util', () => {
}
});

it('should preserves asynchronous dynamic entry points', async () => {
it('should preserve asynchronous dynamic entry points', async () => {
let i = 0;
const webpackOptions = {
// simulate async dynamic entry
Expand Down Expand Up @@ -121,7 +121,7 @@ describe('addEntries util', () => {
}
});

it("should prepends webpack's hot reload client script", () => {
it("should prepend webpack's hot reload client script", () => {
const webpackOptions = Object.assign({}, config, {
entry: {
app: './app.js',
Expand All @@ -138,7 +138,7 @@ describe('addEntries util', () => {
expect(hotClientScript).toEqual(require.resolve(hotClientScript));
});

it("should prepends webpack's hot only client script", () => {
it("should prepend webpack's hot only client script", () => {
const webpackOptions = Object.assign({}, config, {
entry: {
app: './app.js',
Expand All @@ -155,23 +155,23 @@ describe('addEntries util', () => {
expect(hotClientScript).toEqual(require.resolve(hotClientScript));
});

it("should doesn't add the HMR plugin if not hot and no plugins", () => {
it('should not add the HMR plugin if not hot and no plugins', () => {
const webpackOptions = Object.assign({}, config);

addEntries(webpackOptions, {});

expect('plugins' in webpackOptions).toBeFalsy();
});

it("should doesn't add the HMR plugin if not hot and empty plugins", () => {
it('should not add the HMR plugin if not hot and empty plugins', () => {
const webpackOptions = Object.assign({}, config, { plugins: [] });

addEntries(webpackOptions, {});

expect(webpackOptions.plugins).toEqual([]);
});

it("should doesn't add the HMR plugin if not hot and some plugins", () => {
it('should not add the HMR plugin if not hot and some plugins', () => {
const existingPlugin1 = new webpack.BannerPlugin('happy birthday');
const existingPlugin2 = new webpack.DefinePlugin({ foo: 'bar' });
const webpackOptions = Object.assign({}, config, {
Expand All @@ -183,7 +183,7 @@ describe('addEntries util', () => {
expect(webpackOptions.plugins).toEqual([existingPlugin1, existingPlugin2]);
});

it('should adds the HMR plugin if hot', () => {
it('should add the HMR plugin if hot', () => {
const existingPlugin = new webpack.BannerPlugin('bruce');
const webpackOptions = Object.assign({}, config, {
plugins: [existingPlugin],
Expand All @@ -197,7 +197,7 @@ describe('addEntries util', () => {
]);
});

it('should adds the HMR plugin if hot-only', () => {
it('should add the HMR plugin if hot-only', () => {
const webpackOptions = Object.assign({}, config);

addEntries(webpackOptions, { hot: 'only' });
Expand All @@ -207,7 +207,7 @@ describe('addEntries util', () => {
]);
});

it("should doesn't add the HMR plugin again if it's already there", () => {
it("should not add the HMR plugin again if it's already there", () => {
const existingPlugin = new webpack.BannerPlugin('bruce');
const webpackOptions = Object.assign({}, config, {
plugins: [new webpack.HotModuleReplacementPlugin(), existingPlugin],
Expand Down Expand Up @@ -240,7 +240,7 @@ describe('addEntries util', () => {
]);
});

it('should can prevent duplicate entries from successive calls', () => {
it('should prevent duplicate entries from successive calls', () => {
const webpackOptions = Object.assign({}, config);

addEntries(webpackOptions, { hot: true });
Expand All @@ -254,15 +254,15 @@ describe('addEntries util', () => {
expect(result.length).toEqual(1);
});

it('should supports entry as Function', () => {
it('should support entry as Function', () => {
const webpackOptions = Object.assign({}, configEntryAsFunction);

addEntries(webpackOptions, {});

expect(typeof webpackOptions.entry === 'function').toBe(true);
});

it('should only prepends devServer entry points to web targets by default', () => {
it('should only prepend devServer entry points to web targets by default', () => {
const webpackOptions = [
Object.assign({}, config),
Object.assign({ target: 'web' }, config),
Expand Down Expand Up @@ -292,7 +292,7 @@ describe('addEntries util', () => {
});
});

it('should allows selecting compilations to inline the client into', () => {
it('should allow selecting compilations to inline the client into', () => {
const webpackOptions = [
Object.assign({}, config),
Object.assign({ target: 'web' }, config),
Expand Down Expand Up @@ -322,7 +322,7 @@ describe('addEntries util', () => {
});
});

it('should prepends the hot runtime to all targets by default (when hot)', () => {
it('should prepend the hot runtime to all targets by default (when hot)', () => {
const webpackOptions = [
Object.assign({ target: 'web' }, config),
Object.assign({ target: 'node' }, config),
Expand All @@ -347,7 +347,7 @@ describe('addEntries util', () => {
});
});

it('should allows selecting which compilations to inject the hot runtime into', () => {
it('should allow selecting which compilations to inject the hot runtime into', () => {
const webpackOptions = [
Object.assign({ target: 'web' }, config),
Object.assign({ target: 'node' }, config),
Expand All @@ -359,7 +359,7 @@ describe('addEntries util', () => {
});

// node target should have the client runtime but not the hot runtime
const webWebpackOptions = webpackOptions[0];
const [webWebpackOptions, nodeWebpackOptions] = webpackOptions;

expect(webWebpackOptions.entry.length).toEqual(2);

Expand All @@ -369,9 +369,6 @@ describe('addEntries util', () => {

expect(normalize(webWebpackOptions.entry[1])).toEqual('./foo.js');

// node target should have the hot runtime but not the client runtime
const nodeWebpackOptions = webpackOptions[1];

expect(nodeWebpackOptions.entry.length).toEqual(2);

expect(
Expand Down

0 comments on commit d14892a

Please sign in to comment.