From 7a8398b9560ac68642fe5e44138bc6c01501db0a Mon Sep 17 00:00:00 2001 From: James Ide Date: Wed, 1 Jul 2015 12:51:59 -0700 Subject: [PATCH 1/2] [Flow] Update flowconfig's version req to 0.13.1, fix Movies example typechecking Summary: This should fix tests. Closes https://github.com/facebook/react-native/pull/1819 Github Author: James Ide Test Plan: Run Travis CI tests. Also run the movies app and verify that there are no invariant violations. --- Examples/Movies/SearchScreen.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Examples/Movies/SearchScreen.js b/Examples/Movies/SearchScreen.js index 21819df46..c0877d978 100644 --- a/Examples/Movies/SearchScreen.js +++ b/Examples/Movies/SearchScreen.js @@ -26,6 +26,8 @@ var { } = React; var TimerMixin = require('react-timer-mixin'); +var invariant = require('invariant'); + var MovieCell = require('./MovieCell'); var MovieScreen = require('./MovieScreen'); @@ -73,18 +75,16 @@ var SearchScreen = React.createClass({ this.searchMovies(''); }, - _urlForQueryAndPage: function(query: string, pageNumber: ?number): string { + _urlForQueryAndPage: function(query: string, pageNumber: number): string { var apiKey = API_KEYS[this.state.queryNumber % API_KEYS.length]; if (query) { return ( - // $FlowFixMe(>=0.13.0) - pageNumber may be null or undefined API_URL + 'movies.json?apikey=' + apiKey + '&q=' + encodeURIComponent(query) + '&page_limit=20&page=' + pageNumber ); } else { // With no query, load latest movies return ( - // $FlowFixMe(>=0.13.0) - pageNumber may be null or undefined API_URL + 'lists/movies/in_theaters.json?apikey=' + apiKey + '&page_limit=20&page=' + pageNumber ); @@ -176,6 +176,7 @@ var SearchScreen = React.createClass({ }); var page = resultsCache.nextPageNumberForQuery[query]; + invariant(page != null, 'Next page number for "%s" is missing', query); fetch(this._urlForQueryAndPage(query, page)) .then((response) => response.json()) .catch((error) => { From 5aa27586f0793b4edc7225303f6828efdd2244a3 Mon Sep 17 00:00:00 2001 From: James Ide Date: Wed, 1 Jul 2015 12:52:10 -0700 Subject: [PATCH 2/2] [Tests] Update tests to run on io.js with the latest version of jest Summary: [This is a preview diff for getting RN's tests to pass with a future version of jest that supports io.js and other future versions of Node. This can be merged once the diff to update jest is merged upstream and published.] Updates the tests in small ways so they run on io.js with two updates: - The Cache test which relies on Promises uses `runAllImmediates` for modern versions of Node because bluebird uses `setImmediate` instead of `process.nextTick` for Node >0.10. Closes https://github.com/facebook/react-native/pull/1382 Github Author: James Ide Test Plan: Run `npm test` with the latest version of jest. --- .../react-packager/src/JSTransformer/__tests__/Cache-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packager/react-packager/src/JSTransformer/__tests__/Cache-test.js b/packager/react-packager/src/JSTransformer/__tests__/Cache-test.js index 3877b3dd5..df3ccfd7e 100644 --- a/packager/react-packager/src/JSTransformer/__tests__/Cache-test.js +++ b/packager/react-packager/src/JSTransformer/__tests__/Cache-test.js @@ -229,7 +229,7 @@ describe('JSTransformer Cache', function() { return Promise.resolve('baz value'); }); - jest.runAllTicks(); + jest.runAllImmediates(); expect(fs.writeFile).toBeCalled(); }); });