Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.

Commit

Permalink
translate tests to es6
Browse files Browse the repository at this point in the history
  • Loading branch information
DudaGod committed Sep 7, 2016
1 parent 55e82aa commit 473bb5e
Showing 1 changed file with 35 additions and 37 deletions.
72 changes: 35 additions & 37 deletions test/unit/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,74 +4,72 @@ const proxyquire = require('proxyquire');

let plugins;

describe('plugins', function() {
beforeEach(function() {
this.foobarPlugin = sinon.spy();
this.gemini = sinon.spy();
describe('plugins', () => {
let foobarPlugin;
let gemini;

beforeEach(() => {
foobarPlugin = sinon.spy();
gemini = sinon.spy();

plugins = proxyquire
.noCallThru()
.load('lib/plugins', {
'gemini-foobar': this.foobarPlugin
'gemini-foobar': foobarPlugin
});
});

describe('load', function() {
it('should load plugin without prefix', function() {
this.gemini.config = {system: {plugins: {foobar: true}}};
describe('load', () => {
it('should load plugin without prefix', () => {
gemini.config = {system: {plugins: {foobar: true}}};

plugins.load(this.gemini);
plugins.load(gemini);

assert.calledWith(this.foobarPlugin, this.gemini, {});
assert.calledWith(foobarPlugin, gemini, {});
});

it('should load plugin with prefix', function() {
this.gemini.config = {system: {plugins: {'gemini-foobar': true}}};
it('should load plugin with prefix', () => {
gemini.config = {system: {plugins: {'gemini-foobar': true}}};

plugins.load(this.gemini);
plugins.load(gemini);

assert.calledWith(this.foobarPlugin, this.gemini, {});
assert.calledWith(foobarPlugin, gemini, {});
});

it('should throw error if plugin not found', function() {
this.gemini.config = {system: {plugins: {'gemini-foo': true}}};
it('should throw error if plugin not found', () => {
gemini.config = {system: {plugins: {'gemini-foo': true}}};

assert.throws(function() {
plugins.load(this.gemini);
});
assert.throws(() => plugins.load(gemini));
});

it('should not load disabled plugins', function() {
this.gemini.config = {system: {plugins: {foobar: false}}};
it('should not load disabled plugins', () => {
gemini.config = {system: {plugins: {foobar: false}}};

plugins.load(this.gemini);
plugins.load(gemini);

assert.notCalled(this.foobarPlugin);
assert.notCalled(foobarPlugin);
});

it('should load plugin with empty configuration', function() {
this.gemini.config = {system: {plugins: {foobar: {}}}};
it('should load plugin with empty configuration', () => {
gemini.config = {system: {plugins: {foobar: {}}}};

plugins.load(this.gemini);
plugins.load(gemini);

assert.calledWith(this.foobarPlugin, this.gemini, {});
assert.calledWith(foobarPlugin, gemini, {});
});

it('should handle empty plugins', function() {
var _this = this;
this.gemini.config = {system: {plugins: {}}};
it('should handle empty plugins', () => {
gemini.config = {system: {plugins: {}}};

assert.doesNotThrow(function() {
plugins.load(_this.gemini);
});
assert.doesNotThrow(() => plugins.load(gemini));
});

it('should pass plugin its configuration', function() {
this.gemini.config = {system: {plugins: {foobar: {foo: 'bar'}}}};
it('should pass plugin its configuration', () => {
gemini.config = {system: {plugins: {foobar: {foo: 'bar'}}}};

plugins.load(this.gemini);
plugins.load(gemini);

assert.calledWith(this.foobarPlugin, this.gemini, {foo: 'bar'});
assert.calledWith(foobarPlugin, gemini, {foo: 'bar'});
});
});
});

0 comments on commit 473bb5e

Please sign in to comment.