-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
48 lines (43 loc) · 1011 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const expect = require('chai').expect;
const HtmlWebpackUncssPlugin = require('./index.js');
const htmlWithUnusedCss = `
<html>
<style>
h1 {
font-size: 3em;
}
.test {
color: red;
}
</style>
<p class="test">hello</p>
</html>
`;
const htmlWithoutUnusedCss = `
<html>
<style>
.test {
color: red;
}
</style>
<p class="test">hello</p>
</html>
`;
describe('plugin', () => {
it('takes no options', () => {
expect(() => new HtmlWebpackUncssPlugin({})).to.throw();
});
it('removes unused CSS', function (done) {
this.timeout(10000);
const plugin = new HtmlWebpackUncssPlugin();
plugin.apply({
plugin: (name, callback) => callback({
plugin: (name, callback) =>
callback({ html: htmlWithUnusedCss }, (err, data) => {
expect(data.html).to.equal(htmlWithoutUnusedCss);
done();
}),
}),
});
});
});