From 13994d5810519c9fc08f892bcf625d2fb0c633a1 Mon Sep 17 00:00:00 2001 From: David Aurelio Date: Sat, 3 Sep 2016 01:11:34 -0700 Subject: [PATCH] re-enable and fix tests Summary: When bringing back `node-haste` to React Native, I left an `fdescribe` in a test that led to ~70 tests being skipped. This re-enables these tests, and fixes test failures Reviewed By: cpojer Differential Revision: D3811225 fbshipit-source-id: 67a16f385759bb829f1f3f559862eab7e78f2097 --- .../Network/__tests__/XMLHttpRequest-test.js | 6 +++-- .../StyleSheet/__tests__/processColor-test.js | 25 +++++++++++-------- .../__tests__/DependencyGraph-test.js | 14 ++++++----- 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/Libraries/Network/__tests__/XMLHttpRequest-test.js b/Libraries/Network/__tests__/XMLHttpRequest-test.js index a369f237d8f49c..fbc0bbe36fcf5e 100644 --- a/Libraries/Network/__tests__/XMLHttpRequest-test.js +++ b/Libraries/Network/__tests__/XMLHttpRequest-test.js @@ -16,8 +16,10 @@ jest Networking: { addListener: function() {}, removeListeners: function() {}, - sendRequest: (options, callback) => { - callback(1); + sendRequest(options, callback) { + if (typeof callback === 'function') { // android does not pass a callback + callback(1); + } }, abortRequest: function() {}, } diff --git a/Libraries/StyleSheet/__tests__/processColor-test.js b/Libraries/StyleSheet/__tests__/processColor-test.js index 38b282289aabf7..b36120c9c828dc 100644 --- a/Libraries/StyleSheet/__tests__/processColor-test.js +++ b/Libraries/StyleSheet/__tests__/processColor-test.js @@ -10,7 +10,12 @@ jest.disableAutomock(); -var processColor = require('processColor'); +const {OS} = require('Platform'); +const processColor = require('processColor'); + +const platformSpecific = OS === 'android' + ? unsigned => unsigned | 0 //eslint-disable-line no-bitwise + : x => x; describe('processColor', () => { @@ -19,25 +24,25 @@ describe('processColor', () => { it('should convert red', () => { var colorFromString = processColor('red'); var expectedInt = 0xFFFF0000; - expect(colorFromString).toEqual(expectedInt); + expect(colorFromString).toEqual(platformSpecific(expectedInt)); }); it('should convert white', () => { var colorFromString = processColor('white'); var expectedInt = 0xFFFFFFFF; - expect(colorFromString).toEqual(expectedInt); + expect(colorFromString).toEqual(platformSpecific(expectedInt)); }); it('should convert black', () => { var colorFromString = processColor('black'); var expectedInt = 0xFF000000; - expect(colorFromString).toEqual(expectedInt); + expect(colorFromString).toEqual(platformSpecific(expectedInt)); }); it('should convert transparent', () => { var colorFromString = processColor('transparent'); var expectedInt = 0x00000000; - expect(colorFromString).toEqual(expectedInt); + expect(colorFromString).toEqual(platformSpecific(expectedInt)); }); }); @@ -46,7 +51,7 @@ describe('processColor', () => { it('should convert rgb(x, y, z)', () => { var colorFromString = processColor('rgb(10, 20, 30)'); var expectedInt = 0xFF0A141E; - expect(colorFromString).toEqual(expectedInt); + expect(colorFromString).toEqual(platformSpecific(expectedInt)); }); }); @@ -56,7 +61,7 @@ describe('processColor', () => { it('should convert rgba(x, y, z, a)', () => { var colorFromString = processColor('rgba(10, 20, 30, 0.4)'); var expectedInt = 0x660A141E; - expect(colorFromString).toEqual(expectedInt); + expect(colorFromString).toEqual(platformSpecific(expectedInt)); }); }); @@ -66,7 +71,7 @@ describe('processColor', () => { it('should convert hsl(x, y%, z%)', () => { var colorFromString = processColor('hsl(318, 69%, 55%)'); var expectedInt = 0xFFDB3DAC; - expect(colorFromString).toEqual(expectedInt); + expect(colorFromString).toEqual(platformSpecific(expectedInt)); }); }); @@ -76,7 +81,7 @@ describe('processColor', () => { it('should convert hsla(x, y%, z%, a)', () => { var colorFromString = processColor('hsla(318, 69%, 55%, 0.25)'); var expectedInt = 0x40DB3DAC; - expect(colorFromString).toEqual(expectedInt); + expect(colorFromString).toEqual(platformSpecific(expectedInt)); }); }); @@ -86,7 +91,7 @@ describe('processColor', () => { it('should convert #xxxxxx', () => { var colorFromString = processColor('#1e83c9'); var expectedInt = 0xFF1E83C9; - expect(colorFromString).toEqual(expectedInt); + expect(colorFromString).toEqual(platformSpecific(expectedInt)); }); }); diff --git a/packager/react-packager/src/node-haste/__tests__/DependencyGraph-test.js b/packager/react-packager/src/node-haste/__tests__/DependencyGraph-test.js index f5d1510d502047..bf3ec649d684d8 100644 --- a/packager/react-packager/src/node-haste/__tests__/DependencyGraph-test.js +++ b/packager/react-packager/src/node-haste/__tests__/DependencyGraph-test.js @@ -1273,8 +1273,8 @@ describe('DependencyGraph', function() { `Failed to build DependencyGraph: @providesModule naming collision:\n` + ` Duplicate module name: index\n` + ` Paths: /root/b.js collides with /root/index.js\n\n` + - `This error is caused by a @providesModule declaration ` + - `with the same name across two different files.` + 'This error is caused by a @providesModule declaration ' + + 'with the same name across two different files.' ); expect(err.type).toEqual('DependencyGraphError'); }); @@ -2608,15 +2608,17 @@ describe('DependencyGraph', function() { let DependencyGraph; beforeEach(function() { process.platform = 'win32'; - DependencyGraph = require('../index'); // force reload with fastpath + + // force reload with fastpath + jest.resetModules(); + DependencyGraph = require('../index'); }); afterEach(function() { process.platform = realPlatform; }); - pit('should get dependencies', function() { - process.platform = 'win32'; + it('should get dependencies', function() { const root = 'C:\\root'; setMockFileSystem({ 'root': { @@ -6080,7 +6082,7 @@ describe('DependencyGraph', function() { }); }); - fdescribe('Deterministic order of dependencies', () => { + describe('Deterministic order of dependencies', () => { let callDeferreds, dependencyGraph, moduleReadDeferreds; let moduleRead; let DependencyGraph;