浏览代码

proving HOC works with redux

Daniel Zlotin 6 年前
父节点
当前提交
bd8837a2ce
共有 1 个文件被更改,包括 19 次插入0 次删除
  1. 19
    0
      integration/redux/Redux.test.js

+ 19
- 0
integration/redux/Redux.test.js 查看文件

@@ -29,6 +29,25 @@ describe('redux support', () => {
29 29
     expect(tree.toJSON().children).toEqual(['no name']);
30 30
   });
31 31
 
32
+  it('passes props into wrapped components', () => {
33
+    const renderCountIncrement = jest.fn();
34
+
35
+    const HOC = class extends React.Component {
36
+      render() {
37
+        return (
38
+          <Provider store={store.reduxStore}>
39
+            <MyConnectedComponent {...this.props}/>
40
+          </Provider>
41
+        );
42
+      }
43
+    };
44
+    Navigation.registerComponent('ComponentName', () => HOC);
45
+
46
+    const tree = renderer.create(<HOC renderCountIncrement={renderCountIncrement}/>);
47
+    expect(tree.toJSON().children).toEqual(['no name']);
48
+    expect(renderCountIncrement).toHaveBeenCalledTimes(1);
49
+  });
50
+
32 51
   it('rerenders as a result of an underlying state change (by selector)', () => {
33 52
     const renderCountIncrement = jest.fn();
34 53
     const tree = renderer.create(