mirror of https://github.com/status-im/metro.git
Fix server tests
Summary: @public Invoking an extra promise caused failures in the promise-based tests. This fixes them. Reviewed By: @vjeux Differential Revision: D2432431
This commit is contained in:
parent
270b1c718f
commit
676c1c3a45
|
@ -155,7 +155,7 @@ describe('processRequest', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
pit('rebuilds the bundles that contain a file when that file is changed', () => {
|
it('rebuilds the bundles that contain a file when that file is changed', () => {
|
||||||
const bundleFunc = jest.genMockFunction();
|
const bundleFunc = jest.genMockFunction();
|
||||||
bundleFunc
|
bundleFunc
|
||||||
.mockReturnValueOnce(
|
.mockReturnValueOnce(
|
||||||
|
@ -178,21 +178,25 @@ describe('processRequest', () => {
|
||||||
|
|
||||||
requestHandler = server.processRequest.bind(server);
|
requestHandler = server.processRequest.bind(server);
|
||||||
|
|
||||||
return makeRequest(requestHandler, 'mybundle.bundle?runModule=true')
|
makeRequest(requestHandler, 'mybundle.bundle?runModule=true')
|
||||||
.then(response => {
|
.done(response => {
|
||||||
expect(response).toEqual('this is the first source');
|
expect(response).toEqual('this is the first source');
|
||||||
expect(bundleFunc.mock.calls.length).toBe(1);
|
expect(bundleFunc.mock.calls.length).toBe(1);
|
||||||
triggerFileChange('all','path/file.js', options.projectRoots[0]);
|
|
||||||
jest.runAllTimers();
|
|
||||||
jest.runAllTimers();
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
expect(bundleFunc.mock.calls.length).toBe(2);
|
|
||||||
return makeRequest(requestHandler, 'mybundle.bundle?runModule=true')
|
|
||||||
.then(response =>
|
|
||||||
expect(response).toEqual('this is the rebuilt source')
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
jest.runAllTicks();
|
||||||
|
|
||||||
|
triggerFileChange('all','path/file.js', options.projectRoots[0]);
|
||||||
|
jest.runAllTimers();
|
||||||
|
jest.runAllTicks();
|
||||||
|
|
||||||
|
expect(bundleFunc.mock.calls.length).toBe(2);
|
||||||
|
|
||||||
|
makeRequest(requestHandler, 'mybundle.bundle?runModule=true')
|
||||||
|
.done(response =>
|
||||||
|
expect(response).toEqual('this is the rebuilt source')
|
||||||
|
);
|
||||||
|
jest.runAllTicks();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -259,30 +263,33 @@ describe('processRequest', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('buildbundle(options)', () => {
|
describe('buildbundle(options)', () => {
|
||||||
it('Calls the bundler with the correct args', () => {
|
pit('Calls the bundler with the correct args', () => {
|
||||||
server.buildBundle({
|
return server.buildBundle({
|
||||||
entryFile: 'foo file'
|
entryFile: 'foo file'
|
||||||
});
|
}).then(() =>
|
||||||
expect(Bundler.prototype.bundle).toBeCalledWith(
|
expect(Bundler.prototype.bundle).toBeCalledWith(
|
||||||
'foo file',
|
'foo file',
|
||||||
true,
|
true,
|
||||||
undefined,
|
undefined,
|
||||||
true,
|
true,
|
||||||
undefined
|
undefined
|
||||||
|
)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('buildBundleFromUrl(options)', () => {
|
describe('buildBundleFromUrl(options)', () => {
|
||||||
it('Calls the bundler with the correct args', () => {
|
pit('Calls the bundler with the correct args', () => {
|
||||||
server.buildBundleFromUrl('/path/to/foo.bundle?dev=false&runModule=false');
|
return server.buildBundleFromUrl('/path/to/foo.bundle?dev=false&runModule=false')
|
||||||
expect(Bundler.prototype.bundle).toBeCalledWith(
|
.then(() =>
|
||||||
'path/to/foo.js',
|
expect(Bundler.prototype.bundle).toBeCalledWith(
|
||||||
false,
|
'path/to/foo.js',
|
||||||
'/path/to/foo.map?dev=false&runModule=false',
|
false,
|
||||||
false,
|
'/path/to/foo.map?dev=false&runModule=false',
|
||||||
undefined
|
false,
|
||||||
);
|
undefined
|
||||||
|
)
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue