Skip to content

Commit

Permalink
fix(reload): Allow multiple instances to call their own .reload() m…
Browse files Browse the repository at this point in the history
…ethod - fixes #511
  • Loading branch information
shakyShane committed Mar 13, 2015
1 parent 0b48055 commit da53dc2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,10 @@ function getSingle(name) {
*/
function create(name, emitter) {

name = name || new Date().getTime();
var browserSync = new BrowserSync(emitter || newEmitter(), name);
name = name || new Date().getTime();
emitter = emitter || newEmitter();

var browserSync = new BrowserSync(emitter, name);

var instance = {
name: name,
Expand Down
16 changes: 11 additions & 5 deletions test/specs/api/init.reload.multi.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@ var assert = require("chai").assert;

describe("API: .reload() with multi instances", function () {

var clock, bs1, bs2;
var clock, bs1, bs2, emitter1, emitter2;

before(function (done) {
browserSync.reset();

bs1 = browserSync.create("Server 1").init({logLevel:"silent"}, function () {
bs2 = browserSync.create("Server 2").init({logLevel: "silent"}, function () {
browserSync.create("Server 1").init({logLevel:"silent"}, function (err, bs) {
bs1 = bs;
emitter1 = sinon.spy(bs.events, "emit");
browserSync.create("Server 2").init({logLevel: "silent"}, function (err, bs) {
bs2 = bs;
emitter2 = sinon.spy(bs.events, "emit");
done();
}).instance;
}).instance;
});
});

clock = sinon.useFakeTimers();
});
Expand All @@ -26,6 +30,8 @@ describe("API: .reload() with multi instances", function () {
});

after(function () {
bs1.cleanup();
bs2.cleanup();
clock.restore();
});

Expand Down

0 comments on commit da53dc2

Please sign in to comment.