This repository has been archived by the owner on Jun 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
test.js
66 lines (52 loc) · 1.72 KB
/
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* eslint no-undef: 0 */
'use strict';
const expect = require('chai').expect;
const Plugin = require('./');
describe('Plugin', () => {
let plugin;
beforeEach(() => {
plugin = new Plugin({});
});
it('should be an object', () => expect(plugin).to.be.ok);
it('should has #optimize method', () => {
expect(plugin.optimize).to.be.an.instanceof(Function);
});
it('should compile and produce valid result', done => {
const content = '#first { font-size: 14px; color: #b0b; }';
const expected = '#first{font-size:14px;color:#b0b}';
plugin.optimize({data: content, path: ''})
.then(data => {
expect(data).to.equal(expected);
done();
})
.catch(error => expect(error).not.to.be.ok);
});
it('should compile and produce a result clean-css options are reflected in', done => {
plugin.options = {level: 2, specialComments: false};
const eol = require('os').EOL;
const content = '#first { color: red; }\r\n#second { color: blue; }';
const expected = `#first{color:red}#second{color:#00f}`;
plugin.optimize({data: content, path: ''})
.then(data => {
expect(data).to.equal(expected);
done();
})
.catch(error => {
console.log(error);
expect(error).not.to.be.ok
});
});
it('should return a non minified css if path is in "ignore" list', done => {
plugin.options = {
ignored: /ignore-me\.css/,
};
const content = '#first { font-size: 14px; color: #b0b; }';
const expected = content;
plugin.optimize({data: content, path: 'dist/ignore-me.css'})
.then(data => {
expect(data).to.equal(expected);
done();
})
.catch(error => expect(error).not.to.be.ok);
});
});