Skip to content

Commit

Permalink
reorder/rename test for null/undefined link assets
Browse files Browse the repository at this point in the history
  • Loading branch information
swimmadude66 committed Jun 24, 2021
1 parent 7ef88bd commit 805e53c
Showing 1 changed file with 27 additions and 21 deletions.
48 changes: 27 additions & 21 deletions spec/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,33 @@ configs.forEach(c => {
});
});

it('should not fail on meta links', (done) => {
webpack({ ...c.options,
plugins: [
...c.options.plugins,
new HtmlWebpackPlugin({
...HtmlWebpackPluginOptions,
meta: {
robots: `none`,
},
}),
new HtmlWebpackSkipAssetsPlugin({
skipAssets: [/styles\..*js/]
}),
]
}, (err, stats) => {
expect(!!err).to.be.false;
expect(stats.hasErrors()).to.be.false;
const html = getOutput();
expect(/script\s+.*?src\s*=\s*"(\/)?polyfill(\.[a-z0-9]+\.min)?\.js"/i.test(html), 'could not find polyfill bundle').to.be.true;
expect(/script\s+.*?src\s*=\s*"(\/)?app(\.[a-z0-9]+\.min)?\.js"/i.test(html), 'could not find app bundle').to.be.true;
expect(/script\s+.*?src\s*=\s*"(\/)?styles(\.[a-z0-9]+\.min)?\.js"/i.test(html), 'did not skip styles js bundle').to.be.false;
expect(/link\s+.*?href\s*=\s*"(\/)?styles(\.[a-z0-9]+\.min)?\.css"/i.test(html), 'could not find styles css bundle').to.be.true;
expect(/meta\s+.*?name\s*=\s*"robots"/i.test(html), 'could not find meta tag').to.be.true;
done();
});
});

it('should skip adding asset if the pattern matches - plugin.skipAssets.minimatch', (done) => {
webpack({ ...c.options,
plugins: [
Expand Down Expand Up @@ -460,26 +487,5 @@ configs.forEach(c => {
done();
});
});

it('should not fail on meta links - plugin.skipAssets.regex', (done) => {
webpack({ ...c.options,
plugins: [
...c.options.plugins,
new HtmlWebpackPlugin({
...HtmlWebpackPluginOptions,
meta: {
robots: `none`,
},
}),
new HtmlWebpackSkipAssetsPlugin({
skipAssets: [/styles.js/]
}),
]
}, (err, stats) => {
expect(!!err).to.be.false;
expect(stats.hasErrors()).to.be.false;
done();
});
});
});
});

0 comments on commit 805e53c

Please sign in to comment.