Unit test reloading when hot loading is enabled

Reviewed By: sahrens

Differential Revision: D2824276

fb-gh-sync-id: a81acd20eb5b7d3da61becac00e4bdbea6b61a2f
This commit is contained in:
Martín Bigio 2016-01-21 09:51:18 -08:00 committed by facebook-github-bot-4
parent da3838f6ca
commit 18e5e50e11
1 changed files with 14 additions and 2 deletions

View File

@ -165,6 +165,18 @@ describe('processRequest', () => {
});
it('rebuilds the bundles that contain a file when that file is changed', () => {
testChangingFileWith(() => new Server(options));
});
it('rebuilds the bundles that contain a file when that file is changed, even when hot loading is enabled', () => {
testChangingFileWith(() => {
const server = new Server(options);
server.setHMRFileChangeListener(() => Promise.resolve());
return server;
});
});
function testChangingFileWith(createServer) {
const bundleFunc = jest.genMockFunction();
bundleFunc
.mockReturnValueOnce(
@ -182,7 +194,7 @@ describe('processRequest', () => {
Bundler.prototype.bundle = bundleFunc;
server = new Server(options);
server = createServer();
requestHandler = server.processRequest.bind(server);
@ -205,7 +217,7 @@ describe('processRequest', () => {
expect(response).toEqual('this is the rebuilt source')
);
jest.runAllTicks();
});
}
});
describe('/onchange endpoint', () => {