| 
				
			 | 
			
			
				@@ -20,63 +20,72 @@ describe('ComponentRegistry', () => { 
			 | 
		
	
		
			
			| 
				20
			 | 
			
				20
			 | 
			
			
				     uut = require('./ContainerRegistry'); 
			 | 
		
	
		
			
			| 
				21
			 | 
			
				21
			 | 
			
			
				   }); 
			 | 
		
	
		
			
			| 
				22
			 | 
			
				22
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				23
			 | 
			
				
			 | 
			
			
				-  function getRegisteredComponentClassFromAppRegistry() { 
			 | 
		
	
		
			
			| 
				24
			 | 
			
				
			 | 
			
			
				-    return AppRegistry.registerComponent.mock.calls[0][1](); 
			 | 
		
	
		
			
			| 
				25
			 | 
			
				
			 | 
			
			
				-  } 
			 | 
		
	
		
			
			| 
				26
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				27
			 | 
			
				
			 | 
			
			
				-  it('registers container component by containerKey into AppRegistry', () => { 
			 | 
		
	
		
			
			| 
				28
			 | 
			
				
			 | 
			
			
				-    expect(AppRegistry.registerComponent).not.toHaveBeenCalled(); 
			 | 
		
	
		
			
			| 
				29
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				30
			 | 
			
				
			 | 
			
			
				-    uut.registerContainer('example.MyContainer.key', () => MyContainer); 
			 | 
		
	
		
			
			| 
				31
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				32
			 | 
			
				
			 | 
			
			
				-    expect(AppRegistry.registerComponent).toHaveBeenCalledTimes(1); 
			 | 
		
	
		
			
			| 
				33
			 | 
			
				
			 | 
			
			
				-    expect(AppRegistry.registerComponent.mock.calls[0][0]).toEqual('example.MyContainer.key'); 
			 | 
		
	
		
			
			| 
				34
			 | 
			
				
			 | 
			
			
				-  }); 
			 | 
		
	
		
			
			| 
				35
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				36
			 | 
			
				
			 | 
			
			
				-  it('wraps the container', () => { 
			 | 
		
	
		
			
			| 
				37
			 | 
			
				
			 | 
			
			
				-    uut.registerContainer('example.MyContainer', () => MyContainer); 
			 | 
		
	
		
			
			| 
				38
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				39
			 | 
			
				
			 | 
			
			
				-    const NavigationContainer = getRegisteredComponentClassFromAppRegistry(); 
			 | 
		
	
		
			
			| 
				40
			 | 
			
				
			 | 
			
			
				-    const tree = renderer.create( 
			 | 
		
	
		
			
			| 
				41
			 | 
			
				
			 | 
			
			
				-      <NavigationContainer/> 
			 | 
		
	
		
			
			| 
				42
			 | 
			
				
			 | 
			
			
				-    ); 
			 | 
		
	
		
			
			| 
				43
			 | 
			
				
			 | 
			
			
				-    expect(tree.toJSON().children).toEqual(['Hello, World!']); 
			 | 
		
	
		
			
			| 
				44
			 | 
			
				
			 | 
			
			
				-  }); 
			 | 
		
	
		
			
			| 
				45
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				46
			 | 
			
				
			 | 
			
			
				-  it('passes props from wrapper into original container', () => { 
			 | 
		
	
		
			
			| 
				47
			 | 
			
				
			 | 
			
			
				-    uut.registerContainer('example.MyContainer', () => MyContainer); 
			 | 
		
	
		
			
			| 
				48
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				49
			 | 
			
				
			 | 
			
			
				-    const NavigationContainer = getRegisteredComponentClassFromAppRegistry(); 
			 | 
		
	
		
			
			| 
				50
			 | 
			
				
			 | 
			
			
				-    const tree = renderer.create( 
			 | 
		
	
		
			
			| 
				51
			 | 
			
				
			 | 
			
			
				-      <NavigationContainer name="Daniel"/> 
			 | 
		
	
		
			
			| 
				52
			 | 
			
				
			 | 
			
			
				-    ); 
			 | 
		
	
		
			
			| 
				53
			 | 
			
				
			 | 
			
			
				-    expect(tree.toJSON().children).toEqual(['Hello, Daniel!']); 
			 | 
		
	
		
			
			| 
				54
			 | 
			
				
			 | 
			
			
				-  }); 
			 | 
		
	
		
			
			| 
				55
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				56
			 | 
			
				
			 | 
			
			
				-  it('updates props into original container', () => { 
			 | 
		
	
		
			
			| 
				57
			 | 
			
				
			 | 
			
			
				-    uut.registerContainer('example.MyContainer', () => MyContainer); 
			 | 
		
	
		
			
			| 
				58
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				59
			 | 
			
				
			 | 
			
			
				-    const NavigationContainer = getRegisteredComponentClassFromAppRegistry(); 
			 | 
		
	
		
			
			| 
				60
			 | 
			
				
			 | 
			
			
				-    let testParentRef = null; 
			 | 
		
	
		
			
			| 
				61
			 | 
			
				
			 | 
			
			
				-    class TestParent extends Component { //eslint-disable-line 
			 | 
		
	
		
			
			| 
				62
			 | 
			
				
			 | 
			
			
				-      constructor(props) { 
			 | 
		
	
		
			
			| 
				63
			 | 
			
				
			 | 
			
			
				-        super(props); 
			 | 
		
	
		
			
			| 
				64
			 | 
			
				
			 | 
			
			
				-        this.state = {}; 
			 | 
		
	
		
			
			| 
				65
			 | 
			
				
			 | 
			
			
				-      } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				23
			 | 
			
			
				+  describe('registerContainer', () => { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				24
			 | 
			
			
				+    function getRegisteredComponentClassFromAppRegistry() { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				25
			 | 
			
			
				+      return AppRegistry.registerComponent.mock.calls[0][1](); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				26
			 | 
			
			
				+    } 
			 | 
		
	
		
			
			| 
				66
			 | 
			
				27
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				67
			 | 
			
				
			 | 
			
			
				-      render() { 
			 | 
		
	
		
			
			| 
				68
			 | 
			
				
			 | 
			
			
				-        return ( 
			 | 
		
	
		
			
			| 
				69
			 | 
			
				
			 | 
			
			
				-          <NavigationContainer name={this.state.name}/> 
			 | 
		
	
		
			
			| 
				70
			 | 
			
				
			 | 
			
			
				-        ); 
			 | 
		
	
		
			
			| 
				71
			 | 
			
				
			 | 
			
			
				-      } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				28
			 | 
			
			
				+    function renderRegisteredContainer(props) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				29
			 | 
			
			
				+      const Container = getRegisteredComponentClassFromAppRegistry(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				30
			 | 
			
			
				+      return renderer.create( 
			 | 
		
	
		
			
			| 
				
			 | 
			
				31
			 | 
			
			
				+        <Container screenId="screen1" {...props}/> 
			 | 
		
	
		
			
			| 
				
			 | 
			
				32
			 | 
			
			
				+      ); 
			 | 
		
	
		
			
			| 
				72
			 | 
			
				33
			 | 
			
			
				     } 
			 | 
		
	
		
			
			| 
				73
			 | 
			
				34
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				74
			 | 
			
				
			 | 
			
			
				-    const tree = renderer.create( 
			 | 
		
	
		
			
			| 
				75
			 | 
			
				
			 | 
			
			
				-      <TestParent ref={(r) => testParentRef = r}/> 
			 | 
		
	
		
			
			| 
				76
			 | 
			
				
			 | 
			
			
				-    ); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				35
			 | 
			
			
				+    it('registers container component by containerKey into AppRegistry', () => { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				36
			 | 
			
			
				+      expect(AppRegistry.registerComponent).not.toHaveBeenCalled(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				37
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				38
			 | 
			
			
				+      uut.registerContainer('example.MyContainer.key', () => MyContainer); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				39
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				40
			 | 
			
			
				+      expect(AppRegistry.registerComponent).toHaveBeenCalledTimes(1); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				41
			 | 
			
			
				+      expect(AppRegistry.registerComponent.mock.calls[0][0]).toEqual('example.MyContainer.key'); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				42
			 | 
			
			
				+    }); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				43
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				44
			 | 
			
			
				+    it('wraps the container', () => { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				45
			 | 
			
			
				+      uut.registerContainer('example.MyContainer', () => MyContainer); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				46
			 | 
			
			
				+      const tree = renderRegisteredContainer(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				47
			 | 
			
			
				+      expect(tree.toJSON().children).toEqual(['Hello, World!']); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				48
			 | 
			
			
				+    }); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				49
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				50
			 | 
			
			
				+    it('passes props from wrapper into original container', () => { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				51
			 | 
			
			
				+      uut.registerContainer('example.MyContainer', () => MyContainer); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				52
			 | 
			
			
				+      const tree = renderRegisteredContainer({name: 'Daniel'}); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				53
			 | 
			
			
				+      expect(tree.toJSON().children).toEqual(['Hello, Daniel!']); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				54
			 | 
			
			
				+    }); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				55
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				56
			 | 
			
			
				+    it('injects and updates props into original container', () => { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				57
			 | 
			
			
				+      uut.registerContainer('example.MyContainer', () => MyContainer); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				58
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				59
			 | 
			
			
				+      const NavigationContainer = getRegisteredComponentClassFromAppRegistry(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				60
			 | 
			
			
				+      class TestParent extends Component { //eslint-disable-line 
			 | 
		
	
		
			
			| 
				
			 | 
			
				61
			 | 
			
			
				+        constructor(props) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				62
			 | 
			
			
				+          super(props); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				63
			 | 
			
			
				+          this.state = {}; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				64
			 | 
			
			
				+        } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				65
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				66
			 | 
			
			
				+        render() { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				67
			 | 
			
			
				+          return ( 
			 | 
		
	
		
			
			| 
				
			 | 
			
				68
			 | 
			
			
				+            <NavigationContainer screenId="screen1" name={this.state.name}/> 
			 | 
		
	
		
			
			| 
				
			 | 
			
				69
			 | 
			
			
				+          ); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				70
			 | 
			
			
				+        } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				71
			 | 
			
			
				+      } 
			 | 
		
	
		
			
			| 
				77
			 | 
			
				72
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				78
			 | 
			
				
			 | 
			
			
				-    expect(tree.toJSON().children).toEqual(['Hello, World!']); 
			 | 
		
	
		
			
			| 
				79
			 | 
			
				
			 | 
			
			
				-    testParentRef.setState({name: 'Gandalf'}); 
			 | 
		
	
		
			
			| 
				80
			 | 
			
				
			 | 
			
			
				-    expect(tree.toJSON().children).toEqual(['Hello, Gandalf!']); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				73
			 | 
			
			
				+      let testParentRef = null; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				74
			 | 
			
			
				+      const tree = renderer.create( 
			 | 
		
	
		
			
			| 
				
			 | 
			
				75
			 | 
			
			
				+        <TestParent ref={(r) => testParentRef = r}/> 
			 | 
		
	
		
			
			| 
				
			 | 
			
				76
			 | 
			
			
				+      ); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				77
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				78
			 | 
			
			
				+      expect(tree.toJSON().children).toEqual(['Hello, World!']); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				79
			 | 
			
			
				+      testParentRef.setState({name: 'Gandalf'}); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				80
			 | 
			
			
				+      expect(tree.toJSON().children).toEqual(['Hello, Gandalf!']); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				81
			 | 
			
			
				+    }); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				82
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				83
			 | 
			
			
				+    it('asserts has screenId as prop', () => { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				84
			 | 
			
			
				+      uut.registerContainer('example.MyContainer.key', () => MyContainer); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				85
			 | 
			
			
				+      const NavigationContainer = getRegisteredComponentClassFromAppRegistry(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				86
			 | 
			
			
				+      expect(() => { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				87
			 | 
			
			
				+        renderer.create(<NavigationContainer/>); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				88
			 | 
			
			
				+      }).toThrow(new Error('Screen example.MyContainer.key does not have a screenId!')); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				89
			 | 
			
			
				+    }); 
			 | 
		
	
		
			
			| 
				81
			 | 
			
				90
			 | 
			
			
				   }); 
			 | 
		
	
		
			
			| 
				82
			 | 
			
				91
			 | 
			
			
				 }); 
			 |