Skip to content

Commit

Permalink
fixup! Show error overlay even after browser refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
richardscarrott committed Oct 5, 2016
1 parent 22d1f1b commit 443ffa9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 11 deletions.
26 changes: 15 additions & 11 deletions test/client-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,21 @@ describe("client", function() {
sinon.assert.calledWithNew(window.EventSource);
sinon.assert.calledWith(window.EventSource, '/__webpack_hmr');
});
it("should trigger webpack on successful builds", function() {
var eventSource = window.EventSource.lastCall.returnValue;
eventSource.onmessage(makeMessage({
action: 'built',
time: 100,
hash: 'deadbeeffeddad',
errors: [],
warnings: [],
modules: []
}));
sinon.assert.calledOnce(processUpdate);
it("should trigger webpack on successful builds / syncs", function() {
const actions = ['built', 'sync'];
actions.forEach(function(action, i) {
var eventSource = window.EventSource.lastCall.returnValue;
eventSource.onmessage(makeMessage({
action: action,
time: 100,
hash: 'deadbeeffeddad',
errors: [],
warnings: [],
modules: []
}));
sinon.assert.calledOnce(processUpdate);
processUpdate.reset();
});
});
it("should call subscribeAll handler on default messages", function() {
var spy = sinon.spy();
Expand Down
18 changes: 18 additions & 0 deletions test/middleware-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,24 @@ describe("middleware", function() {
}
});
});
it("should notify new clients about current compilation state", function(done) {
compiler.emit("done", stats({
time: 100,
hash: "deadbeeffeddad",
warnings: false,
errors: false,
modules: []
}));

request('/__webpack_hmr')
.end(function(err, res) {
if (err) return done(err);
assert.equal(res.events.length, 1);
var event = JSON.parse(res.events[0].substring(5));
assert.equal(event.action, "sync");
done();
});
});
it("should have tests on the payload of bundle complete");
it("should notify all clients", function(done) {
request('/__webpack_hmr')
Expand Down

0 comments on commit 443ffa9

Please sign in to comment.