| 
				
			 | 
			
			
				@@ -5,14 +5,19 @@ import { ComponentWrapper } from './ComponentWrapper'; 
			 | 
		
	
		
			
			| 
				5
			 | 
			
				5
			 | 
			
			
				 import { ComponentEventsObserver } from '../events/ComponentEventsObserver'; 
			 | 
		
	
		
			
			| 
				6
			 | 
			
				6
			 | 
			
			
				 import { AppRegistryService } from '../adapters/AppRegistryService'; 
			 | 
		
	
		
			
			| 
				7
			 | 
			
				7
			 | 
			
			
				 import { ComponentProvider } from 'react-native'; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				8
			 | 
			
			
				+import * as React from 'react'; 
			 | 
		
	
		
			
			| 
				8
			 | 
			
				9
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				9
			 | 
			
				10
			 | 
			
			
				 const DummyComponent = () => null; 
			 | 
		
	
		
			
			| 
				10
			 | 
			
				11
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
			 | 
			
				12
			 | 
			
			
				+class MyComponent extends React.Component<any, any> {} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				13
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				11
			 | 
			
				14
			 | 
			
			
				 describe('ComponentRegistry', () => { 
			 | 
		
	
		
			
			| 
				12
			 | 
			
				15
			 | 
			
			
				   let mockedStore: Store; 
			 | 
		
	
		
			
			| 
				13
			 | 
			
				16
			 | 
			
			
				   let mockedComponentEventsObserver: ComponentEventsObserver; 
			 | 
		
	
		
			
			| 
				14
			 | 
			
				17
			 | 
			
			
				   let mockedComponentWrapper: ComponentWrapper; 
			 | 
		
	
		
			
			| 
				15
			 | 
			
				18
			 | 
			
			
				   let mockedAppRegistryService: AppRegistryService; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				19
			 | 
			
			
				+  let componentWrapper: ComponentWrapper; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				20
			 | 
			
			
				+  let store: Store; 
			 | 
		
	
		
			
			| 
				16
			 | 
			
				21
			 | 
			
			
				   let uut: ComponentRegistry; 
			 | 
		
	
		
			
			| 
				17
			 | 
			
				22
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				18
			 | 
			
				23
			 | 
			
			
				   beforeEach(() => { 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -20,11 +25,13 @@ describe('ComponentRegistry', () => { 
			 | 
		
	
		
			
			| 
				20
			 | 
			
				25
			 | 
			
			
				     mockedComponentEventsObserver = mock(ComponentEventsObserver); 
			 | 
		
	
		
			
			| 
				21
			 | 
			
				26
			 | 
			
			
				     mockedComponentWrapper = mock(ComponentWrapper); 
			 | 
		
	
		
			
			| 
				22
			 | 
			
				27
			 | 
			
			
				     mockedAppRegistryService = mock(AppRegistryService); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				28
			 | 
			
			
				+    store = instance(mockedStore); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				29
			 | 
			
			
				+    componentWrapper = instance(mockedComponentWrapper); 
			 | 
		
	
		
			
			| 
				23
			 | 
			
				30
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				24
			 | 
			
				31
			 | 
			
			
				     uut = new ComponentRegistry( 
			 | 
		
	
		
			
			| 
				25
			 | 
			
				
			 | 
			
			
				-      instance(mockedStore), 
			 | 
		
	
		
			
			| 
				
			 | 
			
				32
			 | 
			
			
				+      store, 
			 | 
		
	
		
			
			| 
				26
			 | 
			
				33
			 | 
			
			
				       instance(mockedComponentEventsObserver), 
			 | 
		
	
		
			
			| 
				27
			 | 
			
				
			 | 
			
			
				-      instance(mockedComponentWrapper), 
			 | 
		
	
		
			
			| 
				
			 | 
			
				34
			 | 
			
			
				+      componentWrapper, 
			 | 
		
	
		
			
			| 
				28
			 | 
			
				35
			 | 
			
			
				       instance(mockedAppRegistryService) 
			 | 
		
	
		
			
			| 
				29
			 | 
			
				36
			 | 
			
			
				     ); 
			 | 
		
	
		
			
			| 
				30
			 | 
			
				37
			 | 
			
			
				   }); 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -48,4 +55,17 @@ describe('ComponentRegistry', () => { 
			 | 
		
	
		
			
			| 
				48
			 | 
			
				55
			 | 
			
			
				     uut.registerComponent('example.MyComponent.name', generator); 
			 | 
		
	
		
			
			| 
				49
			 | 
			
				56
			 | 
			
			
				     expect(generator).toHaveBeenCalledTimes(0); 
			 | 
		
	
		
			
			| 
				50
			 | 
			
				57
			 | 
			
			
				   }); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				58
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				59
			 | 
			
			
				+  it('should wrap component only once', () => { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				60
			 | 
			
			
				+    componentWrapper.wrap = jest.fn(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				61
			 | 
			
			
				+    let wrappedComponent: React.ComponentClass<any>; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				62
			 | 
			
			
				+    store.hasRegisteredWrappedComponent = jest.fn(() => wrappedComponent !== undefined); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				63
			 | 
			
			
				+    store.setWrappedComponent = jest.fn(() => wrappedComponent = MyComponent); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				64
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				65
			 | 
			
			
				+    const generator: ComponentProvider = jest.fn(() => DummyComponent); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				66
			 | 
			
			
				+    uut.registerComponent('example.MyComponent.name', generator)(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				67
			 | 
			
			
				+    uut.registerComponent('example.MyComponent.name', generator)(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				68
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				69
			 | 
			
			
				+    expect(componentWrapper.wrap).toHaveBeenCalledTimes(1); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				70
			 | 
			
			
				+  }); 
			 | 
		
	
		
			
			| 
				51
			 | 
			
				71
			 | 
			
			
				 }); 
			 |