From 473bb5e56ab6654626d6912f16064ea75e4cbf8c Mon Sep 17 00:00:00 2001 From: DudaGod Date: Wed, 7 Sep 2016 18:47:24 +0300 Subject: [PATCH] translate tests to es6 --- test/unit/plugins.js | 72 +++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 37 deletions(-) diff --git a/test/unit/plugins.js b/test/unit/plugins.js index 84c7faf44..e155e5a87 100644 --- a/test/unit/plugins.js +++ b/test/unit/plugins.js @@ -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'}); }); }); });