Skip to content
This repository has been archived by the owner on Feb 9, 2023. It is now read-only.

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shvaikalesh committed Sep 7, 2016
1 parent 2dbf7ec commit 883f64b
Showing 1 changed file with 22 additions and 23 deletions.
45 changes: 22 additions & 23 deletions test.js
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 =;'});
});
});
});

0 comments on commit 883f64b

Please sign in to comment.