webpack-hot-middleware
Advanced tools
Comparing version 2.11.0 to 2.12.0
@@ -124,2 +124,3 @@ /*eslint-env browser*/ | ||
var customHandler; | ||
var subscribeAllHandler; | ||
function processMessage(obj) { | ||
@@ -148,2 +149,6 @@ if (obj.action == "building") { | ||
} | ||
if (subscribeAllHandler) { | ||
subscribeAllHandler(obj); | ||
} | ||
} | ||
@@ -153,2 +158,5 @@ | ||
module.exports = { | ||
subscribeAll: function subscribeAll(handler) { | ||
subscribeAllHandler = handler; | ||
}, | ||
subscribe: function subscribe(handler) { | ||
@@ -155,0 +163,0 @@ customHandler = handler; |
{ | ||
"name": "webpack-hot-middleware", | ||
"version": "2.11.0", | ||
"version": "2.12.0", | ||
"description": "Webpack hot reloading you can attach to your own server", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -42,2 +42,32 @@ /* eslint-env mocha, browser */ | ||
}); | ||
it("should call subscribeAll handler on default messages", function() { | ||
var spy = sinon.spy(); | ||
client.subscribeAll(spy); | ||
var message = { | ||
action: 'built', | ||
time: 100, | ||
hash: 'deadbeeffeddad', | ||
errors: [], | ||
warnings: [], | ||
modules: [] | ||
}; | ||
var eventSource = window.EventSource.lastCall.returnValue; | ||
eventSource.onmessage(makeMessage(message)); | ||
sinon.assert.calledOnce(spy); | ||
sinon.assert.calledWith(spy, message); | ||
}); | ||
it("should call subscribeAll handler on custom messages", function() { | ||
var spy = sinon.spy(); | ||
client.subscribeAll(spy); | ||
var eventSource = window.EventSource.lastCall.returnValue; | ||
eventSource.onmessage(makeMessage({ | ||
action: 'thingy' | ||
})); | ||
sinon.assert.calledOnce(spy); | ||
sinon.assert.calledWith(spy, { action: 'thingy' }); | ||
}); | ||
it("should call only custom handler on custom messages", function() { | ||
@@ -51,2 +81,5 @@ var spy = sinon.spy(); | ||
})); | ||
eventSource.onmessage(makeMessage({ | ||
action: 'built' | ||
})); | ||
@@ -53,0 +86,0 @@ sinon.assert.calledOnce(spy); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39589
878