Skip to content

Commit

Permalink
fix(plugins): allow module references in options.plugins array - fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
shakyShane committed May 28, 2015
1 parent 4c5002d commit aabc03c
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/async.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ module.exports = {
}

if (Immutable.Map.isMap(item)) {
loadPlugin(item.get("module"), item.get("options"));
if (item.has("module")) {
loadPlugin(item.get("module"), item.get("options"));
} else {
loadPlugin(item);
}
}
});

Expand Down
1 change: 0 additions & 1 deletion test/specs/plugins/user.plugins.inline.obj.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ describe("Plugins: Retrieving user plugins when given inline as object", functio
instance.cleanup();
});
it("Should access to only the user-specified plugins", function (done) {
console.log(instance.getUserPlugins());
assert.equal(instance.getUserPlugins().length, 1);
done();
});
Expand Down
50 changes: 50 additions & 0 deletions test/specs/plugins/user.plugins.inline.obj.reference.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"use strict";

var assert = require("chai").assert;
var sinon = require("sinon");

describe("Plugins: Retrieving user plugins when given inline as object reference", function () {

var instance;
var PLUGIN_NAME_1 = "Test Plugin 1";
var PLUGIN_NAME_2 = "Test Plugin 2";
var spy1, spy2;

before(function (done) {

var browserSync = require("../../../");
spy1 = sinon.spy();
spy2 = sinon.spy();
browserSync.reset();

var bs = browserSync.create();

var fake1 = {
plugin: spy1,
"plugin:name": PLUGIN_NAME_1
};
var fake2 = {
plugin: spy1,
"plugin:name": PLUGIN_NAME_2
};

var config = {
logLevel: "silent",
plugins: [fake1, fake2]
};

instance = bs.init(config, done);
});
after(function () {
instance.cleanup();
});
it("Should access to only the user-specified plugins", function (done) {
assert.equal(instance.getUserPlugins().length, 2);
done();
});
it("Should have access to only the user-specified plugins", function (done) {
assert.equal(instance.getUserPlugins()[0].name, PLUGIN_NAME_1);
assert.equal(instance.getUserPlugins()[1].name, PLUGIN_NAME_2);
done();
});
});

0 comments on commit aabc03c

Please sign in to comment.