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();
|
||||
bundleFunc
|
||||
.mockReturnValueOnce(
|
||||
|
@ -178,21 +178,25 @@ describe('processRequest', () => {
|
|||
|
||||
requestHandler = server.processRequest.bind(server);
|
||||
|
||||
return makeRequest(requestHandler, 'mybundle.bundle?runModule=true')
|
||||
.then(response => {
|
||||
makeRequest(requestHandler, 'mybundle.bundle?runModule=true')
|
||||
.done(response => {
|
||||
expect(response).toEqual('this is the first source');
|
||||
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)', () => {
|
||||
it('Calls the bundler with the correct args', () => {
|
||||
server.buildBundle({
|
||||
pit('Calls the bundler with the correct args', () => {
|
||||
return server.buildBundle({
|
||||
entryFile: 'foo file'
|
||||
});
|
||||
expect(Bundler.prototype.bundle).toBeCalledWith(
|
||||
'foo file',
|
||||
true,
|
||||
undefined,
|
||||
true,
|
||||
undefined
|
||||
}).then(() =>
|
||||
expect(Bundler.prototype.bundle).toBeCalledWith(
|
||||
'foo file',
|
||||
true,
|
||||
undefined,
|
||||
true,
|
||||
undefined
|
||||
)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('buildBundleFromUrl(options)', () => {
|
||||
it('Calls the bundler with the correct args', () => {
|
||||
server.buildBundleFromUrl('/path/to/foo.bundle?dev=false&runModule=false');
|
||||
expect(Bundler.prototype.bundle).toBeCalledWith(
|
||||
'path/to/foo.js',
|
||||
false,
|
||||
'/path/to/foo.map?dev=false&runModule=false',
|
||||
false,
|
||||
undefined
|
||||
);
|
||||
pit('Calls the bundler with the correct args', () => {
|
||||
return server.buildBundleFromUrl('/path/to/foo.bundle?dev=false&runModule=false')
|
||||
.then(() =>
|
||||
expect(Bundler.prototype.bundle).toBeCalledWith(
|
||||
'path/to/foo.js',
|
||||
false,
|
||||
'/path/to/foo.map?dev=false&runModule=false',
|
||||
false,
|
||||
undefined
|
||||
)
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue