This repository has been archived by the owner on Feb 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
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
2dbf7ec
commit 883f64b
Showing
1 changed file
with
22 additions
and
23 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,41 +1,40 @@ | ||
var expect = require('chai').expect; | ||
var Plugin = require('./'); | ||
'use strict'; | ||
|
||
describe('Plugin', function() { | ||
var plugin; | ||
const expect = require('chai').expect; | ||
const Plugin = require('./'); | ||
|
||
beforeEach(function() { | ||
plugin = new Plugin({}); | ||
describe(Plugin.name, () => { | ||
let plugin; | ||
|
||
beforeEach(() => { | ||
plugin = new Plugin({plugins: {}}); | ||
}); | ||
|
||
it('should be an object', function() { | ||
expect(plugin).to.be.ok; | ||
it('should be an object', () => { | ||
expect(plugin).to.be.an('object'); | ||
}); | ||
|
||
it('should has #compile method', function() { | ||
expect(plugin.compile).to.be.an.instanceof(Function); | ||
it('should have #compile method', () => { | ||
expect(plugin).to.respondTo('compile'); | ||
}); | ||
|
||
it('should compile and produce valid result', function(done) { | ||
var content = 'var a = 6;'; | ||
var expected = 'var a = 6;'; | ||
it('should compile and produce valid result', () => { | ||
const data = 'var a = 6;'; | ||
|
||
plugin.compile({data: content, path: 'file.js'}).then(result => { | ||
var data = result.data; | ||
expect(data).to.equal(expected); | ||
done(); | ||
}, error => expect(error).not.to.be.ok); | ||
return plugin.compile({data}).then(result => { | ||
expect(result.data).to.equal(data); | ||
}); | ||
}); | ||
|
||
it('should validate JS syntax', function(done) { | ||
plugin.compile({data: 'var a =;', path: 'file.js'}).then(null, error => { | ||
it('should validate JS syntax', () => { | ||
return plugin.compile({data: 'var a =;'}).catch(error => { | ||
expect(error).to.be.an.instanceof(Error); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should not validate JS syntax with an option', function(done) { | ||
it('should not validate JS syntax with an option', () => { | ||
plugin = new Plugin({plugins: {javascript: {validate: false}}}); | ||
plugin.compile({data: 'var a =;', path: 'file.js'}).then(() => done(), error => expect(error).not.to.be.ok); | ||
return plugin.compile({data: 'var a =;'}); | ||
}); | ||
}); | ||
}); |