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 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c1728c8
commit a012b48
Showing
1 changed file
with
41 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,66 @@ | ||
global.expect = require('chai').expect; | ||
global.Plugin = require('./'); | ||
describe('Plugin', function() { | ||
var plugin; | ||
/* eslint no-undef: 0 */ | ||
'use strict'; | ||
|
||
beforeEach(function() { | ||
const expect = require('chai').expect; | ||
const Plugin = require('./'); | ||
|
||
describe('Plugin', () => { | ||
let plugin; | ||
|
||
beforeEach(() => { | ||
plugin = new Plugin({}); | ||
}); | ||
|
||
it('should be an object', function() { | ||
expect(plugin).to.be.ok; | ||
}); | ||
it('should be an object', () => expect(plugin).to.be.ok); | ||
|
||
it('should has #optimize method', function() { | ||
it('should has #optimize method', () => { | ||
expect(plugin.optimize).to.be.an.instanceof(Function); | ||
}); | ||
|
||
it('should compile and produce valid result', function(done) { | ||
var content = '#first { font-size: 14px; color: #b0b; }'; | ||
var expected = '#first{font-size:14px;color:#b0b}'; | ||
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(); | ||
}, error => expect(error).not.to.be.ok); | ||
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', function(done) { | ||
it('should compile and produce a result clean-css options are reflected in', done => { | ||
plugin.options = { | ||
keepSpecialComments: 0, | ||
keepBreaks: true | ||
keepBreaks: true, | ||
}; | ||
|
||
var eol = require('os').EOL; | ||
const eol = require('os').EOL; | ||
|
||
var content = '/*! comment */\n#first { color: red; }\r\n#second { color: blue; }'; | ||
var expected = '#first{color:red}' + eol + '#second{color:#00f}'; | ||
const content = '/*! comment */\n#first { color: red; }\r\n#second { color: blue; }'; | ||
const expected = `#first{color:red}${eol}#second{color:#00f}`; | ||
|
||
plugin.optimize({data: content, path: ''}).then(data => { | ||
expect(data).to.equal(expected); | ||
done(); | ||
}, error => expect(error).not.to.be.ok); | ||
plugin.optimize({data: content, path: ''}) | ||
.then(data => { | ||
expect(data).to.equal(expected); | ||
done(); | ||
}) | ||
.catch(error => expect(error).not.to.be.ok); | ||
}); | ||
|
||
it('should return a non minified css if path is in "ignore" list', function(done) { | ||
it('should return a non minified css if path is in "ignore" list', done => { | ||
plugin.options = { | ||
ignored: /ignore-me\.css/ | ||
ignored: /ignore-me\.css/, | ||
}; | ||
|
||
var content = '#first { font-size: 14px; color: #b0b; }'; | ||
var expected = content; | ||
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(); | ||
}, error => expect(error).not.to.be.ok); | ||
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); | ||
}); | ||
|
||
|
||
}); |