File tree Expand file tree Collapse file tree 3 files changed +2099
-4
lines changed
Expand file tree Collapse file tree 3 files changed +2099
-4
lines changed Original file line number Diff line number Diff line change 2424 "homepage" : " https://github.com/csabapalfi/html-webpack-uncss-plugin" ,
2525 "dependencies" : {
2626 "cheerio" : " ^0.22.0" ,
27- "uncss " : " ^0.14 .1" ,
28- "snyk " : " ^1.22 .1"
27+ "snyk " : " ^1.22 .1" ,
28+ "uncss " : " ^0.14 .1"
2929 },
3030 "scripts" : {
31- "test" : " snyk test" ,
31+ "test:snyk" : " snyk test" ,
32+ "test:mocha" : " mocha" ,
33+ "test" : " npm run test:mocha && npm run test:snyk" ,
3234 "snyk-protect" : " snyk protect" ,
3335 "prepublish" : " npm run snyk-protect"
3436 },
35- "snyk" : true
37+ "snyk" : true ,
38+ "devDependencies" : {
39+ "chai" : " ^3.5.0" ,
40+ "mocha" : " ^3.2.0"
41+ }
3642}
Original file line number Diff line number Diff line change 1+ const expect = require ( 'chai' ) . expect ;
2+
3+ const HtmlWebpackUncssPlugin = require ( './index.js' ) ;
4+
5+ const htmlWithUnusedCss = `
6+ <html>
7+ <style>
8+ h1 {
9+ font-size: 3em;
10+ }
11+ .test {
12+ color: red;
13+ }
14+ </style>
15+ <p class="test">hello</p>
16+ </html>
17+ ` ;
18+
19+ const htmlWithoutUnusedCss = `
20+ <html>
21+ <style>
22+ .test {
23+ color: red;
24+ }
25+ </style>
26+ <p class="test">hello</p>
27+ </html>
28+ ` ;
29+
30+ describe ( 'plugin' , ( ) => {
31+ it ( 'takes no options' , ( ) => {
32+ expect ( ( ) => new HtmlWebpackUncssPlugin ( { } ) ) . to . throw ( ) ;
33+ } ) ;
34+
35+ it ( 'removes unused CSS' , function ( done ) {
36+ this . timeout ( 10000 ) ;
37+ const plugin = new HtmlWebpackUncssPlugin ( ) ;
38+ plugin . apply ( {
39+ plugin : ( name , callback ) => callback ( {
40+ plugin : ( name , callback ) =>
41+ callback ( { html : htmlWithUnusedCss } , ( err , data ) => {
42+ expect ( data . html ) . to . equal ( htmlWithoutUnusedCss ) ;
43+ done ( ) ;
44+ } ) ,
45+ } ) ,
46+ } ) ;
47+ } ) ;
48+ } ) ;
You can’t perform that action at this time.
0 commit comments