Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

Commit

Permalink
refactor: remove extractComments duplicate test
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Jul 30, 2018
1 parent 35d357a commit 5117df5
Showing 1 changed file with 0 additions and 53 deletions.
53 changes: 0 additions & 53 deletions test/extractComments-option.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,59 +53,6 @@ describe('when options.extractComments', () => {
});
});

it('outputs warnings for unreachable code', () => {
const pluginEnvironment = new PluginEnvironment();
const compilerEnv = pluginEnvironment.getEnvironmentStub();
compilerEnv.context = '';

const plugin = new UglifyJsPlugin({
uglifyOptions: {
warnings: true,
mangle: {
properties: {
builtins: true,
},
},
},
extractComments: true,
});
plugin.apply(compilerEnv);

const [eventBinding] = pluginEnvironment.getEventBindings();
const chunkPluginEnvironment = new PluginEnvironment();

const compilation = chunkPluginEnvironment.getEnvironmentStub();
compilation.assets = {
'test.js': {
source: () => 'var foo = 1;',
},
'test1.js': {
source: () => 'function foo(x) { if (x) { return bar(); not_called1(); } }',
map: () => {
return {
version: 3,
sources: ['test1.js'],
names: ['foo', 'x', 'bar', 'not_called1'],
mappings: 'AAAA,QAASA,KAAIC,GACT,GAAIA,EAAG,CACH,MAAOC,MACPC',
};
},
},
};
compilation.warnings = [];
compilation.errors = [];

eventBinding.handler(compilation);
const [compilationEventBinding] = chunkPluginEnvironment.getEventBindings();

compilationEventBinding.handler([{
files: ['test.js', 'test1.js'],
}], () => {
expect(compilation.warnings.length).toBe(1);
expect(compilation.warnings[0]).toBeInstanceOf(Error);
expect(compilation.warnings[0].message).toEqual(expect.stringContaining('Dropping unreachable code'));
});
});

it('normalizes when options.extractComments is not specify', () => {
const pluginEnvironment = new PluginEnvironment();
const compilerEnv = pluginEnvironment.getEnvironmentStub();
Expand Down

0 comments on commit 5117df5

Please sign in to comment.