Skip to content
This repository has been archived by the owner on Oct 13, 2018. It is now read-only.

Commit

Permalink
allow notify messages that have 'override: true' - part of BrowserSyn…
Browse files Browse the repository at this point in the history
  • Loading branch information
shakyShane committed Feb 13, 2017
1 parent 057f745 commit 6b10879
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/notify.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ exports.init = function (bs) {
*/
exports.watchEvent = function (bs) {
return function (data) {
if (bs.options.notify) {
if (bs.options.notify || data.override) {
if (typeof data === "string") {
return exports.flash(data);
}
Expand Down
16 changes: 16 additions & 0 deletions test/client-new/notify.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,22 @@ describe("The Notify Element", function() {
stub.restore();
});

it("does not flash a message if notify:false", function(){
var stub = sinon.stub(notify, "flash");
var cb = notify.watchEvent({options: {notify:false}});
cb({message: "custom message"});
sinon.assert.notCalled(stub);
stub.restore();
});

it("DOES flash a message if notify:false but override: true", function(){
var stub = sinon.stub(notify, "flash");
var cb = notify.watchEvent({options: {notify:false}});
cb({message: "custom message", override: true});
sinon.assert.calledWithExactly(stub, "custom message", undefined);
stub.restore();
});

it("should register an listener on the emitter", function () {
var spy = sinon.spy(bs.emitter, "on");
notify.init(bs);
Expand Down

0 comments on commit 6b10879

Please sign in to comment.