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

Commit

Permalink
test: file-loader should emit assets (#312)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi committed Dec 20, 2018
1 parent 6dcc7e8 commit ad4ff96
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions test/loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,24 @@ describe('loader', () => {
};

const stats = await webpack('fixture.js', config);
const [module] = stats.toJson().modules;
const { source } = module;
const jsonStats = stats.toJson();
const { modules, assets } = jsonStats;
const [{ source }] = modules;

// eslint-disable-next-line no-new-func
const assetName = new Function(
'exports',
'require',
'module',
'__filename',
'__dirname',
`'use strict'\nvar __webpack_public_path__ = '';\nreturn ${source}`
)(exports, require, module, __filename, __dirname);
const hasModuleAsAsset = Boolean(
assets.find((asset) => asset.name === assetName)
);

expect(hasModuleAsAsset).toBe(true);
expect(source).toMatchSnapshot();
});

Expand Down

0 comments on commit ad4ff96

Please sign in to comment.