|
@@ -1,24 +1,26 @@
|
|
1
|
+import {AppRegistry, Text} from 'react-native';
|
|
2
|
+import React, {Component} from 'react';
|
|
3
|
+
|
|
4
|
+class MyContainer extends Component {
|
|
5
|
+ render() {
|
|
6
|
+ return (
|
|
7
|
+ <Text>{'Hello, World!'}</Text>
|
|
8
|
+ );
|
|
9
|
+ }
|
|
10
|
+}
|
|
11
|
+
|
|
12
|
+import renderer from 'react-test-renderer';
|
|
13
|
+
|
1
|
14
|
describe('ComponentRegistry', () => {
|
2
|
15
|
let uut;
|
3
|
|
- let AppRegistry;
|
4
|
|
- let MyContainer, Component;
|
5
|
16
|
|
6
|
17
|
beforeEach(() => {
|
7
|
|
- AppRegistry = {registerComponent: jest.fn()};
|
8
|
|
- Component = class {
|
9
|
|
- //
|
10
|
|
- };
|
11
|
|
-
|
12
|
|
- jest.mock('react', () => ({}));
|
13
|
|
- jest.mock('react-native', () => ({AppRegistry, Component}));
|
|
18
|
+ AppRegistry.registerComponent = jest.fn(AppRegistry.registerComponent);
|
|
19
|
+ //jest.mock('react-native', () => ({AppRegistry}));
|
14
|
20
|
uut = require('./ContainerRegistry');
|
15
|
|
-
|
16
|
|
- MyContainer = class extends Component {
|
17
|
|
- //
|
18
|
|
- };
|
19
|
21
|
});
|
20
|
22
|
|
21
|
|
- it('registers container component into AppRegistry', () => {
|
|
23
|
+ xit('registers container component into AppRegistry', () => {
|
22
|
24
|
expect(AppRegistry.registerComponent).not.toHaveBeenCalled();
|
23
|
25
|
|
24
|
26
|
uut.registerContainer('example.MyContainer', () => MyContainer);
|
|
@@ -26,4 +28,14 @@ describe('ComponentRegistry', () => {
|
26
|
28
|
expect(AppRegistry.registerComponent).toHaveBeenCalledTimes(1);
|
27
|
29
|
expect(AppRegistry.registerComponent.mock.calls[0][0]).toEqual('example.MyContainer');
|
28
|
30
|
});
|
|
31
|
+
|
|
32
|
+ it('wraps the container', () => {
|
|
33
|
+ uut.registerContainer('example.MyContainer', () => MyContainer);
|
|
34
|
+
|
|
35
|
+ const WrappedClass = AppRegistry.registerComponent.mock.calls[0][1]();
|
|
36
|
+ const tree = renderer.create(
|
|
37
|
+ <WrappedClass/>
|
|
38
|
+ );
|
|
39
|
+ console.log(tree.toJSON())
|
|
40
|
+ });
|
29
|
41
|
});
|