Skip to content

Commit 7c53add

Browse files
cpojerFacebook Github Bot 6
authored and
Facebook Github Bot 6
committed
First snapshot test, rendering "native" React component.
Reviewed By: frantic Differential Revision: D3449781 fbshipit-source-id: 7abf9280f98cee06d04d7e222b884de1744afb8d
1 parent 52d5450 commit 7c53add

File tree

6 files changed

+144
-2
lines changed

6 files changed

+144
-2
lines changed

Libraries/BatchedBridge/BatchedBridgedModules/__mocks__/NativeModules.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
/**
2-
* Copyright 2004-present Facebook. All Rights Reserved.
2+
* Copyright (c) 2013-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*
39
*/
410
'use strict';
511

@@ -27,7 +33,14 @@ var NativeModules = {
2733
UIManager: {
2834
customBubblingEventTypes: {},
2935
customDirectEventTypes: {},
30-
Dimensions: {},
36+
Dimensions: {
37+
window: {
38+
width: 750,
39+
height: 1334,
40+
scale: 2,
41+
fontScale: 2,
42+
}
43+
},
3144
RCTModalFullscreenView: {
3245
Constants: {},
3346
},
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*/
9+
10+
jest.disableAutomock();
11+
12+
jest.mock('NativeModules')
13+
.mock('Text')
14+
.mock('ensureComponentIsNative')
15+
.mock('View');
16+
17+
const React = require('React');
18+
const ReactTestRenderer = require('ReactTestRenderer');
19+
const Text = require('Text');
20+
const TouchableHighlight = require('TouchableHighlight');
21+
22+
describe('TouchableHighlight', () => {
23+
it('renders correctly', () => {
24+
const instance = ReactTestRenderer.create(
25+
<TouchableHighlight style={{}}>
26+
<Text>Touchable</Text>
27+
</TouchableHighlight>
28+
);
29+
30+
expect(instance.toJSON()).toMatchSnapshot();
31+
});
32+
});
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
exports[`TouchableHighlight renders correctly 0`] = `
2+
<View
3+
accessible={true}
4+
accessibilityLabel={undefined}
5+
accessibilityComponentType={undefined}
6+
accessibilityTraits={undefined}
7+
style={
8+
Array [
9+
4,
10+
Object {}
11+
]
12+
}
13+
onLayout={undefined}
14+
hitSlop={undefined}
15+
onStartShouldSetResponder={[Function bound touchableHandleStartShouldSetResponder]}
16+
onResponderTerminationRequest={[Function bound touchableHandleResponderTerminationRequest]}
17+
onResponderGrant={[Function bound touchableHandleResponderGrant]}
18+
onResponderMove={[Function bound touchableHandleResponderMove]}
19+
onResponderRelease={[Function bound touchableHandleResponderRelease]}
20+
onResponderTerminate={[Function bound touchableHandleResponderTerminate]}
21+
testID={undefined}>
22+
<Text>
23+
Touchable
24+
</Text>
25+
</View>
26+
`;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*
9+
*/
10+
'use strict';
11+
12+
const React = require('React');
13+
const StyleSheetPropType = require('StyleSheetPropType');
14+
const ViewStylePropTypes = require('ViewStylePropTypes');
15+
16+
class View extends React.Component {
17+
render() {
18+
const {children, ...props} = this.props;
19+
return React.createElement('View', props, children);
20+
}
21+
}
22+
23+
View.propTypes = {
24+
style: StyleSheetPropType(ViewStylePropTypes),
25+
};
26+
27+
module.exports = View;

Libraries/Image/__mocks__/Image.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*
9+
*/
10+
'use strict';
11+
12+
const React = require('React');
13+
const {Component} = React;
14+
15+
class Image extends Component {
16+
render() {
17+
const {children, ...props} = this.props;
18+
return React.createElement('Image', props, children);
19+
}
20+
}
21+
22+
module.exports = Image;

Libraries/Text/__mocks__/Text.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*
9+
*/
10+
'use strict';
11+
12+
const React = require('React');
13+
const {Component} = React;
14+
15+
class Text extends Component {
16+
render() {
17+
const {children, ...props} = this.props;
18+
return React.createElement('Text', props, children);
19+
}
20+
}
21+
22+
module.exports = Text;

0 commit comments

Comments
 (0)