forked from facebook/react
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mock UIManager Comment out dontMock that actually needs mocking
- Loading branch information
1 parent
91e62c7
commit d8e8ea5
Showing
14 changed files
with
275 additions
and
2 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
src/renderers/native/ReactNative/__mocks__/InitializeJavaScriptAppEngine.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* Copyright 2013-2015, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
// Noop | ||
|
||
// TODO: Move all initialization callers back into react-native |
16 changes: 16 additions & 0 deletions
16
src/renderers/native/ReactNative/__mocks__/InteractionManager.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* Copyright 2013-2015, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
// TODO: Figure out a way to drop this dependency | ||
|
||
var InteractionManager = {}; | ||
|
||
module.exports = InteractionManager; |
14 changes: 14 additions & 0 deletions
14
src/renderers/native/ReactNative/__mocks__/JSTimersExecution.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* Copyright 2013-2015, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
// Noop | ||
|
||
// TODO: Move all initialization callers back into react-native |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* Copyright 2013-2015, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
// Mock of the Native Hooks | ||
|
||
var Platform = {}; | ||
|
||
module.exports = Platform; |
14 changes: 14 additions & 0 deletions
14
src/renderers/native/ReactNative/__mocks__/RCTEventEmitter.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* Copyright 2013-2015, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
// Noop | ||
|
||
// TODO: Move all initialization callers back into react-native |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* Copyright 2013-2015, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
// Noop | ||
|
||
// TODO: Move all initialization callers back into react-native |
17 changes: 17 additions & 0 deletions
17
src/renderers/native/ReactNative/__mocks__/TextInputState.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Copyright 2013-2015, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
// Mock of the Native Hooks | ||
// TODO: Should this move into the components themselves? E.g. focusable | ||
|
||
var TextInputState = {}; | ||
|
||
module.exports = TextInputState; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* Copyright 2013-2015, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
// Mock of the Native Hooks | ||
|
||
var RCTUIManager = { | ||
createView: jest.genMockFunction(), | ||
setChildren: jest.genMockFunction(), | ||
manageChildren: jest.genMockFunction(), | ||
updateView: jest.genMockFunction(), | ||
}; | ||
|
||
module.exports = RCTUIManager; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/** | ||
* Copyright 2013-2015, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
// TODO: Move deepDiffer into react | ||
|
||
var deepDiffer = function(one: any, two: any): bool { | ||
if (one === two) { | ||
// Short circuit on identical object references instead of traversing them. | ||
return false; | ||
} | ||
if ((typeof one === 'function') && (typeof two === 'function')) { | ||
// We consider all functions equal | ||
return false; | ||
} | ||
if ((typeof one !== 'object') || (one === null)) { | ||
// Primitives can be directly compared | ||
return one !== two; | ||
} | ||
if ((typeof two !== 'object') || (two === null)) { | ||
// We know they are different because the previous case would have triggered | ||
// otherwise. | ||
return true; | ||
} | ||
if (one.constructor !== two.constructor) { | ||
return true; | ||
} | ||
if (Array.isArray(one)) { | ||
// We know two is also an array because the constructors are equal | ||
var len = one.length; | ||
if (two.length !== len) { | ||
return true; | ||
} | ||
for (var ii = 0; ii < len; ii++) { | ||
if (deepDiffer(one[ii], two[ii])) { | ||
return true; | ||
} | ||
} | ||
} else { | ||
for (var key in one) { | ||
if (deepDiffer(one[key], two[key])) { | ||
return true; | ||
} | ||
} | ||
for (var twoKey in two) { | ||
// The only case we haven't checked yet is keys that are in two but aren't | ||
// in one, which means they are different. | ||
if (one[twoKey] === undefined && two[twoKey] !== undefined) { | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
}; | ||
|
||
module.exports = deepDiffer; |
16 changes: 16 additions & 0 deletions
16
src/renderers/native/ReactNative/__mocks__/deepFreezeAndThrowOnMutationInDev.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* Copyright 2013-2015, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
// TODO: move into react or fbjs | ||
|
||
var deepFreezeAndThrowOnMutationInDev = function() { }; | ||
|
||
module.exports = deepFreezeAndThrowOnMutationInDev; |
16 changes: 16 additions & 0 deletions
16
src/renderers/native/ReactNative/__mocks__/flattenStyle.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* Copyright 2013-2015, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
// TODO: Move flattenStyle into react | ||
|
||
var flattenStyle = function() { }; | ||
|
||
module.exports = flattenStyle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* Copyright 2013-2015, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
// TODO: Replace all callers with spread | ||
|
||
var merge = function(a, b) { | ||
return {...a, ...b}; | ||
}; | ||
|
||
module.exports = merge; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/renderers/native/ReactNative/__tests__/ReactNativeMount-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* Copyright 2013-2015, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
* @emails react-core | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var React; | ||
var ReactNative; | ||
var createReactNativeComponentClass; | ||
|
||
describe('ReactNative', function() { | ||
beforeEach(function() { | ||
React = require('React'); | ||
ReactNative = require('ReactNative'); | ||
createReactNativeComponentClass = require('createReactNativeComponentClass'); | ||
}); | ||
|
||
it('should be able to create and render a native component', function() { | ||
var View = createReactNativeComponentClass({ | ||
validAttributes: { foo: true }, | ||
uiViewClassName: 'View', | ||
}); | ||
|
||
ReactNative.render(<View foo="test" />, 1); | ||
}); | ||
|
||
}); |