diff --git a/test.js b/test.js index 3f82e4e..f60372f 100644 --- a/test.js +++ b/test.js @@ -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); }); - - });