-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow HMR status handlers to return a Promise
The HMR system will wait until the promise settles before continuing.
- Loading branch information
1 parent
e9f9045
commit e852415
Showing
5 changed files
with
116 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = 1; | ||
--- | ||
module.exports = 2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
var value = require("./file"); | ||
|
||
it("should wait until promises returned by status handlers are fulfilled", (done) => { | ||
var handler = jest.fn(status => { | ||
return Promise.resolve().then(() => { | ||
expect(status).toBe(module.hot.status()); | ||
}); | ||
}); | ||
module.hot.addStatusHandler(handler); | ||
module.hot.accept("./file", () => { | ||
value = require("./file"); | ||
done(); | ||
}); | ||
NEXT(require("../../update")(done, undefined, () => { | ||
expect(module.hot.status()).toBe("idle"); | ||
|
||
expect(handler.mock.calls).toBe([['check'], ['prepare'], ['dispose'], ['apply'], ['idle']]); | ||
done(); | ||
})); | ||
}); | ||
|